public class TFTPClient extends TFTP
Details regarding the TFTP protocol and the format of TFTP packets can be found in RFC 783. But the point of these classes is to keep you from having to worry about the internals.
TFTP
,
TFTPPacket
,
TFTPPacketException
Modifier and Type | Field | Description |
---|---|---|
static int |
DEFAULT_MAX_TIMEOUTS |
The default number of times a receive attempt is allowed to timeout
before ending attempts to retry the receive and failing.
|
_isOpen_, _socket_, _socketFactory_, _timeout_
ASCII_MODE, BINARY_MODE, DEFAULT_PORT, DEFAULT_TIMEOUT, IMAGE_MODE, NETASCII_MODE, OCTET_MODE
Constructor | Description |
---|---|
TFTPClient() |
Creates a TFTPClient instance with a default timeout of DEFAULT_TIMEOUT,
maximum timeouts value of DEFAULT_MAX_TIMEOUTS, a null socket,
and buffered operations disabled.
|
Modifier and Type | Method | Description |
---|---|---|
int |
getMaxTimeouts() |
Returns the maximum number of times a receive attempt is allowed to
timeout before ending attempts to retry the receive and failing.
|
int |
receiveFile(java.lang.String filename,
int mode,
java.io.OutputStream output,
java.lang.String hostname) |
Same as calling
receiveFile(filename, mode, output, hostname, TFTP.DEFAULT_PORT)
|
int |
receiveFile(java.lang.String filename,
int mode,
java.io.OutputStream output,
java.lang.String hostname,
int port) |
Requests a named file from a remote host, writes the
file to an OutputStream, closes the connection, and returns the number
of bytes read.
|
int |
receiveFile(java.lang.String filename,
int mode,
java.io.OutputStream output,
java.net.InetAddress host) |
Same as calling
receiveFile(filename, mode, output, host, TFTP.DEFAULT_PORT)
|
int |
receiveFile(java.lang.String filename,
int mode,
java.io.OutputStream output,
java.net.InetAddress host,
int port) |
Requests a named file from a remote host, writes the
file to an OutputStream, closes the connection, and returns the number
of bytes read.
|
void |
sendFile(java.lang.String filename,
int mode,
java.io.InputStream input,
java.lang.String hostname) |
Same as calling
sendFile(filename, mode, input, hostname, TFTP.DEFAULT_PORT);
|
void |
sendFile(java.lang.String filename,
int mode,
java.io.InputStream input,
java.lang.String hostname,
int port) |
Requests to send a file to a remote host, reads the file from an
InputStream, sends the file to the remote host, and closes the
connection.
|
void |
sendFile(java.lang.String filename,
int mode,
java.io.InputStream input,
java.net.InetAddress host) |
Same as calling
sendFile(filename, mode, input, host, TFTP.DEFAULT_PORT); |
void |
sendFile(java.lang.String filename,
int mode,
java.io.InputStream input,
java.net.InetAddress host,
int port) |
Requests to send a file to a remote host, reads the file from an
InputStream, sends the file to the remote host, and closes the
connection.
|
void |
setMaxTimeouts(int numTimeouts) |
Sets the maximum number of times a receive attempt is allowed to
timeout during a receiveFile() or sendFile() operation before ending
attempts to retry the receive and failing.
|
close, getDefaultTimeout, getLocalAddress, getLocalPort, getSoTimeout, isOpen, open, open, open, setDatagramSocketFactory, setDefaultTimeout, setSoTimeout
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
beginBufferedOps, bufferedReceive, bufferedSend, discardPackets, endBufferedOps, getModeName, receive, send
public static final int DEFAULT_MAX_TIMEOUTS
public TFTPClient()
public void setMaxTimeouts(int numTimeouts)
numTimeouts
- The maximum number of timeouts to allow. Values
less than 1 should not be used, but if they are, they are
treated as 1.public int getMaxTimeouts()
public int receiveFile(java.lang.String filename, int mode, java.io.OutputStream output, java.net.InetAddress host, int port) throws java.io.IOException
filename
- The name of the file to receive.mode
- The TFTP mode of the transfer (one of the MODE constants).output
- The OutputStream to which the file should be written.host
- The remote host serving the file.port
- The port number of the remote TFTP server.java.io.IOException
- If an I/O error occurs. The nature of the
error will be reported in the message.public int receiveFile(java.lang.String filename, int mode, java.io.OutputStream output, java.lang.String hostname, int port) throws java.net.UnknownHostException, java.io.IOException
filename
- The name of the file to receive.mode
- The TFTP mode of the transfer (one of the MODE constants).output
- The OutputStream to which the file should be written.hostname
- The name of the remote host serving the file.port
- The port number of the remote TFTP server.java.io.IOException
- If an I/O error occurs. The nature of the
error will be reported in the message.java.net.UnknownHostException
- If the hostname cannot be resolved.public int receiveFile(java.lang.String filename, int mode, java.io.OutputStream output, java.net.InetAddress host) throws java.io.IOException
receiveFile(filename, mode, output, host, TFTP.DEFAULT_PORT)
filename
- The name of the file to receive.mode
- The TFTP mode of the transfer (one of the MODE constants).output
- The OutputStream to which the file should be written.host
- The remote host serving the file.java.io.IOException
- If an I/O error occurs. The nature of the
error will be reported in the message.public int receiveFile(java.lang.String filename, int mode, java.io.OutputStream output, java.lang.String hostname) throws java.net.UnknownHostException, java.io.IOException
receiveFile(filename, mode, output, hostname, TFTP.DEFAULT_PORT)
filename
- The name of the file to receive.mode
- The TFTP mode of the transfer (one of the MODE constants).output
- The OutputStream to which the file should be written.hostname
- The name of the remote host serving the file.java.io.IOException
- If an I/O error occurs. The nature of the
error will be reported in the message.java.net.UnknownHostException
- If the hostname cannot be resolved.public void sendFile(java.lang.String filename, int mode, java.io.InputStream input, java.net.InetAddress host, int port) throws java.io.IOException
filename
- The name the remote server should use when creating
the file on its file system.mode
- The TFTP mode of the transfer (one of the MODE constants).output
- The InputStream containing the file.host
- The remote host receiving the file.port
- The port number of the remote TFTP server.java.io.IOException
- If an I/O error occurs. The nature of the
error will be reported in the message.public void sendFile(java.lang.String filename, int mode, java.io.InputStream input, java.lang.String hostname, int port) throws java.net.UnknownHostException, java.io.IOException
filename
- The name the remote server should use when creating
the file on its file system.mode
- The TFTP mode of the transfer (one of the MODE constants).output
- The InputStream containing the file.hostname
- The name of the remote host receiving the file.port
- The port number of the remote TFTP server.java.io.IOException
- If an I/O error occurs. The nature of the
error will be reported in the message.java.net.UnknownHostException
- If the hostname cannot be resolved.public void sendFile(java.lang.String filename, int mode, java.io.InputStream input, java.net.InetAddress host) throws java.io.IOException
sendFile(filename, mode, input, host, TFTP.DEFAULT_PORT);
filename
- The name the remote server should use when creating
the file on its file system.mode
- The TFTP mode of the transfer (one of the MODE constants).output
- The InputStream containing the file.hostname
- The name of the remote host receiving the file.port
- The port number of the remote TFTP server.java.io.IOException
- If an I/O error occurs. The nature of the
error will be reported in the message.java.net.UnknownHostException
- If the hostname cannot be resolved.public void sendFile(java.lang.String filename, int mode, java.io.InputStream input, java.lang.String hostname) throws java.net.UnknownHostException, java.io.IOException
sendFile(filename, mode, input, hostname, TFTP.DEFAULT_PORT);
filename
- The name the remote server should use when creating
the file on its file system.mode
- The TFTP mode of the transfer (one of the MODE constants).output
- The InputStream containing the file.hostname
- The name of the remote host receiving the file.port
- The port number of the remote TFTP server.java.io.IOException
- If an I/O error occurs. The nature of the
error will be reported in the message.java.net.UnknownHostException
- If the hostname cannot be resolved.Copyright © 1997-2002 Daniel F. Savarese. All Rights Reserved.