| java.lang.Object com.enterprisedt.net.ftp.FTPClient
FTPClient | public class FTPClient implements FTPClientInterface(Code) | | Supports client-side FTP. Most common
FTP operations are present in this class.
author: Bruce Blackshaw version: $Revision: 1.93 $ |
Constructor Summary | |
public | FTPClient(String remoteHost) Constructor. | public | FTPClient(String remoteHost, int controlPort) Constructor. | public | FTPClient(String remoteHost, int controlPort, int timeout) Constructor. | public | FTPClient(String remoteHost, int controlPort, int timeout, String encoding) Constructor. | public | FTPClient(InetAddress remoteAddr) Constructor. | public | FTPClient(InetAddress remoteAddr, int controlPort) Constructor. | public | FTPClient(InetAddress remoteAddr, int controlPort, int timeout) Constructor. | public | FTPClient(InetAddress remoteAddr, int controlPort, int timeout, String encoding) Constructor. | public | FTPClient() Default constructor should now always be used together with setter methods
in preference to other constructors (now deprecated). |
Method Summary | |
protected void | abort() | public void | account(String accountInfo) Supply account information string to the server. | public void | cancelResume() | public void | cancelTransfer() | public void | cdup() | public void | chdir(String dir) | protected void | checkConnection(boolean shouldBeConnected) Checks if the client has connected to the server and throws an exception if it hasn't. | protected void | chooseTransferMode(String filename) | public static void | clearSOCKS() Clear SOCKS settings. | protected void | closeDataSocket(InputStream stream) Close stream for data socket. | protected void | closeDataSocket(OutputStream stream) | public void | connect() Connects to the server at the address and port number defined
in the constructor. | public boolean | connected() | public void | debugResponses(boolean on) | public void | delete(String remoteFile) | public String[] | dir() | public String[] | dir(String dirname) | public String[] | dir(String dirname, boolean full) | public FTPFile[] | dirDetails(String dirname) | public boolean | exists(String remoteFile) | public String[] | features() | public FTPFile | fileDetails(String name) Uses the MLST command to find out details about the
named file. | protected void | forceResumeOff() Force the resume flag off. | public void | get(String localPath, String remoteFile) | public void | get(OutputStream destStream, String remoteFile) | public byte[] | get(String remoteFile) | public int | getActiveHighPort() Get the upper limit of the port range for active mode. | public String | getActiveIPAddress() Get the active IP address that is set. | public int | getActiveLowPort() Get the lower limit of the port range for active mode. | public static String | getBuildTimestamp() | public FTPConnectMode | getConnectMode() | public String | getControlEncoding() | public int | getControlPort() Returns the control-port being connected to on the remote server. | public int | getDeleteCount() | public boolean | getDetectTransferMode() | public DirectoryEmptyStrings | getDirectoryEmptyMessages() Get class that holds fragments of server messages that indicate a
directory is empty. | public int | getDownloadCount() | public FileNotFoundStrings | getFileNotFoundMessages() Get class that holds fragments of server messages that indicate a file was
not found. | public String | getId() | InputStream | getInputStream() Get the data input stream. | public FTPReply | getLastReply() | public FTPReply | getLastValidReply() | public boolean | getListenOnAllInterfaces() | public FTPMessageListener | getMessageListener() | public long | getMonitorInterval() | OutputStream | getOutputStream() Get the data input stream. | String | getPASVAddress(String pasvReply) | public FTPProgressMonitor | getProgressMonitor() | public FTPProgressMonitorEx | getProgressMonitorEx() | public InetAddress | getRemoteAddr() | public String | getRemoteHost() | String | getRemoteHostName() | public int | getRemotePort() Returns the control-port being connected to on the remote server. | public int | getServerWakeupInterval() Get server wakeup interval in seconds. | public int | getTimeout() | public int | getTransferBufferSize() | public TransferCompleteStrings | getTransferCompleteMessages() Get class that holds fragments of server messages that indicate a transfer completed. | public FTPTransferType | getType() Get the current transfer type
the current type of the transfer,i.e. | public int | getUploadCount() | public static int[] | getVersion() | public String | help(String command) | protected void | initGet(String remoteFile) | protected String | initPut(String remoteFile, boolean append) | public static void | initSOCKS(String port, String host) Set up SOCKS v4/v5 proxy settings. | public static void | initSOCKSAuthentication(String username, String password) Set up SOCKS username and password for SOCKS username/password
authentication. | protected void | initialize(FTPControlSocket control) | public boolean | isAutoPassiveIPSubstitution() | public boolean | isDeleteOnFailure() | public boolean | isStrictReturnCodes() Determine if strict checking of return codes is switched on. | public boolean | isTransferCancelled() | public void | keepAlive() | public String | list(String dirname) | public String | list(String dirname, boolean full) List a directory's contents as one string. | public void | login(String user, String password) Login into an account on the FTP server. | public void | login(String user, String password, String accountInfo) Login into an account on the FTP server. | public void | mkdir(String dir) | public Date | modtime(String remoteFile) | public void | noOperation() Send a "no operation" message that does nothing. | public void | password(String password) Supplies the password for a previously supplied
username to log into the FTP server. | public String | put(String localPath, String remoteFile) | public String | put(InputStream srcStream, String remoteFile) | public String | put(String localPath, String remoteFile, boolean append) | public String | put(InputStream srcStream, String remoteFile, boolean append) | public String | put(byte[] bytes, String remoteFile) | public String | put(byte[] bytes, String remoteFile, boolean append) | public String | pwd() | public void | quit() | public void | quitImmediately() | public String | quote(String command, String[] validCodes) Issue arbitrary ftp commands to the FTP server.
Parameters: command - ftp command to be sent to server Parameters: validCodes - valid return codes for this command. | public String | quote(String command) Issue arbitrary ftp commands to the FTP server. | protected int | readChar(LineNumberReader in) Attempts to read a single character from the given InputStream . | public int | readChunk(BufferedInputStream in, byte[] chunk, int chunksize) Attempts to read a specified number of bytes from the given
InputStream and place it in the given byte-array. | protected String | readLine(LineNumberReader in) Attempts to read a single line from the given InputStream . | FTPReply | readReply() | public void | rename(String from, String to) | public void | resetDeleteCount() Reset the count of deleted files to zero. | public void | resetDownloadCount() Reset the count of downloaded files to zero. | public void | resetTransferMode(FTPTransferType previousType) Reset the transfer mode back to what it should be, if
it has changed. | public void | resetUploadCount() Reset the count of uploaded files to zero. | public void | restart(long size) Issue the RESTart command to the remote server. | public void | resume() | public void | rmdir(String dir) | public FTPReply | sendCommand(String command) | public void | sendServerWakeup() Wake up the server during a transfer to prevent a
timeout from occuring. | public void | setActiveIPAddress(String activeIP) We can force PORT to send a fixed IP address, which can be useful with certain
NAT configurations. | public void | setActivePortRange(int lowest, int highest) Force a certain range of ports to be used in active mode. | public void | setAutoPassiveIPSubstitution(boolean autoPassiveIPSubstitution) | public void | setConnectMode(FTPConnectMode mode) | public void | setControlEncoding(String controlEncoding) Set the control socket's encoding. | public void | setControlPort(int controlPort) Set the control to connect to on the remote server. | public void | setDeleteOnFailure(boolean deleteOnFailure) | public void | setDetectTransferMode(boolean detectTransferMode) | public void | setDirectoryEmptyMessages(DirectoryEmptyStrings dirEmptyStrings) | public void | setFTPFileFactory(FTPFileFactory fileFactory) | public void | setFileNotFoundMessages(FileNotFoundStrings fileNotFoundStrings) | public void | setForceUniqueNames(boolean forceUnique) Set to true if the STOU command is always to be used when
uploading files, even if a filename is supplied. | public void | setId(String id) | public void | setListenOnAllInterfaces(boolean listenOnAll) Listen on all interfaces for active mode transfers (the default). | public void | setMessageListener(FTPMessageListener listener) | public void | setMonitorInterval(long interval) | public void | setPORTIP(String IPAddress) We can force PORT to send a fixed IP address, which can be useful with certain
NAT configurations. | public void | setParserLocale(Locale locale) | public void | setParserLocales(Locale[] locales) | public void | setProgressMonitor(FTPProgressMonitor monitor, long interval) | public void | setProgressMonitor(FTPProgressMonitor monitor) | public void | setProgressMonitorEx(FTPProgressMonitorEx monitorEx) | public void | setRemoteAddr(InetAddress remoteAddr) | public void | setRemoteHost(String remoteHost) | public void | setRemotePort(int remotePort) Set the control to connect to on the remote server. | public void | setServerWakeupInterval(int interval) Set server wakeup interval in seconds. | public void | setStrictReturnCodes(boolean strict) Set strict checking of FTP return codes. | public void | setTimeout(int millis) Set the SO_TIMEOUT in milliseconds on the underlying socket.
If set this means the socket will block in a read operation
only for this length of time - useful if the FTP sever has
hung, for example. | public void | setTransferBufferSize(int size) | public void | setTransferCompleteMessages(TransferCompleteStrings transferCompleteStrings) | public void | setType(FTPTransferType type) | protected void | setupDataSocket() | public boolean | site(String command) Run a site-specific command on the
server. | public long | size(String remoteFile) | public String | stat() Sends stat message to enquire about the status of a
transfer. | public String | system() | public String | toString() | public void | user(String user) Supply the user name to log into an account
on the FTP server. | public void | validateReply(FTPReply reply, String expectedReplyCode) | public void | validateReply(FTPReply reply, String[] expectedReplyCodes) | public void | validateTransfer() Validate that the put() or get() was successful. | protected void | validateTransferOnError(IOException ex) Validate a transfer when an error has occurred on the data channel.
Set a very short transfer in case things have hung. |
CARRIAGE_RETURN | final public static byte CARRIAGE_RETURN(Code) | | Used for ASCII translation
|
DEFAULT_BUFFER_SIZE | final public static int DEFAULT_BUFFER_SIZE(Code) | | Default transfer buffer size
|
DEFAULT_ENCODING | final public static String DEFAULT_ENCODING(Code) | | Default encoding used for control data
|
DEFAULT_LISTING_LOCALES | public static Locale[] DEFAULT_LISTING_LOCALES(Code) | | Default locales
|
DEFAULT_MONITOR_INTERVAL | final public static int DEFAULT_MONITOR_INTERVAL(Code) | | Default byte interval for transfer monitor
|
DEFAULT_TIMEOUT | final public static int DEFAULT_TIMEOUT(Code) | | Default timeout
|
FTP_LINE_SEPARATOR | final public static byte[] FTP_LINE_SEPARATOR(Code) | | Used for ASCII translation
|
LINE_FEED | final public static byte LINE_FEED(Code) | | Used for ASCII translation
|
controlEncoding | protected String controlEncoding(Code) | | Encoding used on control socket
|
controlPort | protected int controlPort(Code) | | Control port number.
|
detectTransferMode | protected boolean detectTransferMode(Code) | | If true, filetypes are autodetected and transfer mode changed to binary/ASCII as
required
|
lastReply | protected FTPReply lastReply(Code) | | Holds the last reply from the server on the control socket
|
lastValidReply | protected FTPReply lastValidReply(Code) | | Holds the last valid reply from the server on the control socket
|
monitorInterval | protected long monitorInterval(Code) | | Bytes transferred in between monitor callbacks
|
remoteHost | protected String remoteHost(Code) | | Name/IP of remote host
|
serverWakeupInterval | protected int serverWakeupInterval(Code) | | Interval in seconds in between server wakeups. O is
not enabled
|
timeout | protected int timeout(Code) | | Socket timeout for both data and control. In
milliseconds
|
transferBufferSize | protected int transferBufferSize(Code) | | Size of transfer buffers
|
transferType | protected FTPTransferType transferType(Code) | | Record of the transfer type - make the default ASCII
|
FTPClient | public FTPClient(String remoteHost, int controlPort) throws IOException, FTPException(Code) | | Constructor. Creates the control
socket
Parameters: remoteHost - the remote hostname Parameters: controlPort - port for control stream (-1 for default port) |
FTPClient | public FTPClient(String remoteHost, int controlPort, int timeout) throws IOException, FTPException(Code) | | Constructor. Creates the control
socket
Parameters: remoteHost - the remote hostname Parameters: controlPort - port for control stream (use -1 for the default port) Parameters: timeout - the length of the timeout, in milliseconds(pass in 0 for no timeout) |
FTPClient | public FTPClient(String remoteHost, int controlPort, int timeout, String encoding) throws IOException, FTPException(Code) | | Constructor. Creates the control
socket
Parameters: remoteHost - the remote hostname Parameters: controlPort - port for control stream (use -1 for the default port) Parameters: timeout - the length of the timeout, in milliseconds(pass in 0 for no timeout) Parameters: encoding - character encoding used for data |
FTPClient | public FTPClient(InetAddress remoteAddr, int controlPort) throws IOException, FTPException(Code) | | Constructor. Creates the control
socket. Allows setting of control port (normally
set by default to 21).
Parameters: remoteAddr - the address of theremote host Parameters: controlPort - port for control stream |
FTPClient | public FTPClient(InetAddress remoteAddr, int controlPort, int timeout) throws IOException, FTPException(Code) | | Constructor. Creates the control
socket. Allows setting of control port (normally
set by default to 21).
Parameters: remoteAddr - the address of theremote host Parameters: controlPort - port for control stream (-1 for default port) Parameters: timeout - the length of the timeout, in milliseconds (pass in 0 for no timeout) |
FTPClient | public FTPClient(InetAddress remoteAddr, int controlPort, int timeout, String encoding) throws IOException, FTPException(Code) | | Constructor. Creates the control
socket. Allows setting of control port (normally
set by default to 21).
Parameters: remoteAddr - the address of theremote host Parameters: controlPort - port for control stream (-1 for default port) Parameters: timeout - the length of the timeout, in milliseconds (pass in 0 for no timeout) Parameters: encoding - character encoding used for data |
FTPClient | public FTPClient()(Code) | | Default constructor should now always be used together with setter methods
in preference to other constructors (now deprecated). The
FTPClient.connect() method is used to perform the actual connection to the remote host - but only
for this constructor. Deprecated constructors connect in the constructor and
connect() is not required (and cannot be called).
|
account | public void account(String accountInfo) throws IOException, FTPException(Code) | | Supply account information string to the server. This can be
used for a variety of purposes - for example, the server could
indicate that a password has expired (by sending 332 in reply to
PASS) and a new password automatically supplied via ACCT. It
is up to the server how it uses this string.
Parameters: accountInfo - account information string |
cancelTransfer | public void cancelTransfer()(Code) | | |
checkConnection | protected void checkConnection(boolean shouldBeConnected) throws FTPException(Code) | | Checks if the client has connected to the server and throws an exception if it hasn't.
This is only intended to be used by subclasses
throws: FTPException - Thrown if the client has not connected to the server. |
clearSOCKS | public static void clearSOCKS()(Code) | | Clear SOCKS settings. Note that setting these properties affects
all TCP sockets in this JVM
|
closeDataSocket | protected void closeDataSocket(InputStream stream)(Code) | | Close stream for data socket. Not for
general use!
Parameters: stream - stream reference |
closeDataSocket | protected void closeDataSocket(OutputStream stream)(Code) | | Close stream for data socket
Parameters: stream - stream reference |
connect | public void connect() throws IOException, FTPException(Code) | | Connects to the server at the address and port number defined
in the constructor. Must be performed before login() or user() is
called.
throws: IOException - Thrown if there is a TCP/IP-related error. throws: FTPException - Thrown if there is an error related to the FTP protocol. |
connected | public boolean connected()(Code) | | Is this client connected?
true if connected, false otherwise |
debugResponses | public void debugResponses(boolean on)(Code) | | Switch debug of responses on or off
Parameters: on - true if you wish to have responses tothe log stream, false otherwise |
features | public String[] features() throws IOException, FTPException(Code) | | Get the server supplied features
string containing server features, or null if no features or notsupported |
fileDetails | public FTPFile fileDetails(String name) throws IOException, FTPException, ParseException(Code) | | Uses the MLST command to find out details about the
named file. A single filename should be supplied. Note
that the MLST command is not supported by many servers.
Parameters: name - name of a file if it exists, an FTPFile object |
forceResumeOff | protected void forceResumeOff()(Code) | | Force the resume flag off. Internal use only.
|
getActiveHighPort | public int getActiveHighPort()(Code) | | Get the upper limit of the port range for active mode.
upper limit, or -1 if not set |
getActiveIPAddress | public String getActiveIPAddress()(Code) | | Get the active IP address that is set.
active IP address or null if not set |
getActiveLowPort | public int getActiveLowPort()(Code) | | Get the lower limit of the port range for active mode.
lower limit, or -1 if not set |
getBuildTimestamp | public static String getBuildTimestamp()(Code) | | Get the build timestamp
d-MMM-yyyy HH:mm:ss z build timestamp |
getControlEncoding | public String getControlEncoding()(Code) | | Get the encoding used for the control connection
Returns the current controlEncoding. |
getDeleteCount | public int getDeleteCount()(Code) | | Get the number of files deleted since the count was
reset
deleted file count |
getDetectTransferMode | public boolean getDetectTransferMode()(Code) | | |
getDirectoryEmptyMessages | public DirectoryEmptyStrings getDirectoryEmptyMessages()(Code) | | Get class that holds fragments of server messages that indicate a
directory is empty. New messages can be added.
The fragments are used when it is necessary to examine the message
returned by a server to see if it is saying a directory is empty.
If an FTP server is returning a different message that still clearly
indicates a directory is empty, use this property to add a new server
fragment to the repository via the add method. It would be helpful to
email support at enterprisedt dot com to inform us of the message so
it can be added to the next build.
messages class |
getDownloadCount | public int getDownloadCount()(Code) | | Get the number of files downloaded since the count was
reset
download file count |
getFileNotFoundMessages | public FileNotFoundStrings getFileNotFoundMessages()(Code) | | Get class that holds fragments of server messages that indicate a file was
not found. New messages can be added.
The fragments are used when it is necessary to examine the message
returned by a server to see if it is saying a file was not found.
If an FTP server is returning a different message that still clearly
indicates a file was not found, use this property to add a new server
fragment to the repository via the add method. It would be helpful to
email support at enterprisedt dot com to inform us of the message so
it can be added to the next build.
messages class |
getId | public String getId()(Code) | | Get the identifying string for this instance
|
getLastReply | public FTPReply getLastReply()(Code) | | Gets the last reply from the server, whether valid or not
reply object encapsulating last server response |
getLastValidReply | public FTPReply getLastValidReply()(Code) | | Gets the latest valid reply from the server
reply object encapsulating last valid server response |
getListenOnAllInterfaces | public boolean getListenOnAllInterfaces()(Code) | | Are we listening on all interfaces in active mode, which is the default?
true if listening on all interfaces, false if listening just on the control interface |
getMonitorInterval | public long getMonitorInterval()(Code) | | |
getPASVAddress | String getPASVAddress(String pasvReply)(Code) | | Get the PASV address string (including port numbers)
Parameters: pasvReply - |
getProgressMonitor | public FTPProgressMonitor getProgressMonitor()(Code) | | Get the reference to the progress monitor
progress monitor |
getProgressMonitorEx | public FTPProgressMonitorEx getProgressMonitorEx()(Code) | | Get reference to the transfer listener
FTPProgressMonitorEx |
getRemoteHostName | String getRemoteHostName()(Code) | | Get the name of the remote host
remote host name |
getRemotePort | public int getRemotePort()(Code) | | Returns the control-port being connected to on the remote server.
Note that this method replaces
FTPClient.getControlPort() .
Returns the port being connected to on the remote server. |
getServerWakeupInterval | public int getServerWakeupInterval()(Code) | | Get server wakeup interval in seconds. A value of 0
means it is disabled (the default).
interval in seconds |
getTimeout | public int getTimeout()(Code) | | Get the TCP timeout
timeout that is used, in milliseconds |
getTransferBufferSize | public int getTransferBufferSize()(Code) | | Get the size of the buffers used in writing to and reading from
the data sockets
transfer buffer size |
getTransferCompleteMessages | public TransferCompleteStrings getTransferCompleteMessages()(Code) | | Get class that holds fragments of server messages that indicate a transfer completed.
New messages can be added.
The fragments are used when it is necessary to examine the message
returned by a server to see if it is saying a transfer completed.
If an FTP server is returning a different message that still clearly
indicates a transfer failed, use this property to add a new server
fragment to the repository via the add method. It would be helpful to
email support at enterprisedt dot com to inform us of the message so
it can be added to the next build.
messages class |
getType | public FTPTransferType getType()(Code) | | Get the current transfer type
the current type of the transfer,i.e. BINARY or ASCII |
getUploadCount | public int getUploadCount()(Code) | | Get the number of files uploaded since the count was
reset
upload file count |
getVersion | public static int[] getVersion()(Code) | | Get the version of edtFTPj
int array of {major,middle,minor} version numbers |
help | public String help(String command) throws IOException, FTPException(Code) | | Get the help text for the specified command
Parameters: command - name of the command to get help on help text from the server for the supplied command |
initGet | protected void initGet(String remoteFile) throws IOException, FTPException(Code) | | Request to the server that the get is set up
Parameters: remoteFile - name of remote file |
initPut | protected String initPut(String remoteFile, boolean append) throws IOException, FTPException(Code) | | Request the server to set up the put
Parameters: remoteFile - name of remote file in current directory Parameters: append - true if appending, false otherwise |
initSOCKS | public static void initSOCKS(String port, String host)(Code) | | Set up SOCKS v4/v5 proxy settings. This can be used if there
is a SOCKS proxy server in place that must be connected thru.
Note that setting these properties directs all TCP
sockets in this JVM to the SOCKS proxy
Parameters: port - SOCKS proxy port Parameters: host - SOCKS proxy hostname |
initSOCKSAuthentication | public static void initSOCKSAuthentication(String username, String password)(Code) | | Set up SOCKS username and password for SOCKS username/password
authentication. Often, no authentication will be required
but the SOCKS server may be configured to request these.
Parameters: username - the SOCKS username Parameters: password - the SOCKS password |
initialize | protected void initialize(FTPControlSocket control) throws IOException(Code) | | Set the control socket explicitly
Parameters: control - control socket reference |
isAutoPassiveIPSubstitution | public boolean isAutoPassiveIPSubstitution()(Code) | | Is automatic substitution of the remote host IP set to
be on for passive mode connections?
true if set on, false otherwise |
isDeleteOnFailure | public boolean isDeleteOnFailure()(Code) | | If true, delete partially written files when exceptions are thrown
during a download
true if delete local file on error |
isStrictReturnCodes | public boolean isStrictReturnCodes()(Code) | | Determine if strict checking of return codes is switched on. If it is
(the default), all return codes must exactly match the expected code.
If strict checking is off, only the first digit must match.
true if strict return code checking, false if non-strict. |
isTransferCancelled | public boolean isTransferCancelled()(Code) | | Has the current transfer been cancelled?
true if cancel, false otherwise |
keepAlive | public void keepAlive() throws IOException, FTPException(Code) | | Tries to keep the current connection alive by
sending an innocuous commmand to signal that the
client is still active
|
list | public String list(String dirname, boolean full) throws IOException, FTPException(Code) | | List a directory's contents as one string. A detailed
listing is available, otherwise just filenames are provided.
The detailed listing varies in details depending on OS and
FTP server.
Parameters: dirname - the name of the directory(not a file mask) Parameters: full - true if detailed listing requiredfalse otherwise a string containing the line separateddirectory listingFTPClient.dir(String,boolean) |
login | public void login(String user, String password) throws IOException, FTPException(Code) | | Login into an account on the FTP server. This
call completes the entire login process. Note that
connect() must be called first.
Parameters: user - user name Parameters: password - user's password |
login | public void login(String user, String password, String accountInfo) throws IOException, FTPException(Code) | | Login into an account on the FTP server. This call completes the
entire login process. This method permits additional account information
to be supplied. FTP servers can use combinations of these parameters in
many different ways, e.g. to pass in proxy details via this method, some
servers use the "user" as 'ftpUser + "@" + ftpHost + " " + ftpProxyUser',
the "password" as the FTP user's password, and the accountInfo as the proxy
password. Note that connect() must be called first.
Parameters: user - user name Parameters: password - user's password Parameters: accountInfo - account info string |
noOperation | public void noOperation() throws IOException, FTPException(Code) | | Send a "no operation" message that does nothing. Can be
called periodically to prevent the connection timing out
|
password | public void password(String password) throws IOException, FTPException(Code) | | Supplies the password for a previously supplied
username to log into the FTP server. Must be
preceeded by the user() method
Parameters: password - The password. |
quote | public String quote(String command, String[] validCodes) throws IOException, FTPException(Code) | | Issue arbitrary ftp commands to the FTP server.
Parameters: command - ftp command to be sent to server Parameters: validCodes - valid return codes for this command. If nullis supplied no validation is performed the text returned by the FTP server |
quote | public String quote(String command) throws IOException, FTPException(Code) | | Issue arbitrary ftp commands to the FTP server.
Parameters: command - ftp command to be sent to server the raw text returned by the FTP server including reply code |
readChar | protected int readChar(LineNumberReader in) throws IOException(Code) | | Attempts to read a single character from the given InputStream .
The purpose of this method is to permit subclasses to execute
any additional code necessary when performing this operation.
Parameters: in - The LineNumberReader to read from. The character read. throws: IOException - Thrown if there was an error while reading. |
readChunk | public int readChunk(BufferedInputStream in, byte[] chunk, int chunksize) throws IOException(Code) | | Attempts to read a specified number of bytes from the given
InputStream and place it in the given byte-array. The
purpose of this method is to permit subclasses to execute any additional
code necessary when performing this operation.
Parameters: in - The InputStream to read from. Parameters: chunk - The byte-array to place read bytes in. Parameters: chunksize - Number of bytes to read. Number of bytes actually read. throws: IOException - Thrown if there was an error while reading. |
readLine | protected String readLine(LineNumberReader in) throws IOException(Code) | | Attempts to read a single line from the given InputStream .
The purpose of this method is to permit subclasses to execute
any additional code necessary when performing this operation.
Parameters: in - The LineNumberReader to read from. The string read. throws: IOException - Thrown if there was an error while reading. |
resetDeleteCount | public void resetDeleteCount()(Code) | | Reset the count of deleted files to zero.
|
resetDownloadCount | public void resetDownloadCount()(Code) | | Reset the count of downloaded files to zero.
|
resetUploadCount | public void resetUploadCount()(Code) | | Reset the count of uploaded files to zero.
|
restart | public void restart(long size) throws IOException, FTPException(Code) | | Issue the RESTart command to the remote server. This indicates the byte
position that REST is performed at. For put, bytes start at this point, while
for get, bytes are fetched from this point.
Parameters: size - the REST param, the mark at which the restart is performed on the remote file. For STOR, this is retrievedby SIZE throws: IOException - throws: FTPException - |
setActiveIPAddress | public void setActiveIPAddress(String activeIP) throws FTPException(Code) | | We can force PORT to send a fixed IP address, which can be useful with certain
NAT configurations. Must be connected to the remote host to call this method.
Parameters: activeIP - IP address to force, in 192.168.1.0 form or in IPV6 form, e.g.1080::8:800:200C:417A |
setActivePortRange | public void setActivePortRange(int lowest, int highest) throws FTPException(Code) | | Force a certain range of ports to be used in active mode. This is
generally so that a port range can be configured in a firewall. Note
that if lowest == highest, a single port will be used. This works well
for uploads, but downloads generally require multiple ports, as most
servers fail to create a connection repeatedly for the same port.
Parameters: lowest - Lower limit of range. Parameters: highest - Upper limit of range. |
setAutoPassiveIPSubstitution | public void setAutoPassiveIPSubstitution(boolean autoPassiveIPSubstitution)(Code) | | Set automatic substitution of the remote host IP on if
in passive mode
Parameters: autoPassiveIPSubstitution - true if set to on, false otherwise |
setConnectMode | public void setConnectMode(FTPConnectMode mode)(Code) | | Set the connect mode
Parameters: mode - ACTIVE or PASV mode |
setControlEncoding | public void setControlEncoding(String controlEncoding) throws FTPException(Code) | | Set the control socket's encoding. Can only do this if
not connected
Parameters: controlEncoding - The controlEncoding to set, which is the name of a Charset See Also: java.nio.charset.Charset throws: FTPException - |
setDeleteOnFailure | public void setDeleteOnFailure(boolean deleteOnFailure)(Code) | | Switch on or off the automatic deletion of partially written files
that are left when an exception is thrown during a download
Parameters: deleteOnFailure - true if delete when a failure occurs |
setDetectTransferMode | public void setDetectTransferMode(boolean detectTransferMode)(Code) | | |
setDirectoryEmptyMessages | public void setDirectoryEmptyMessages(DirectoryEmptyStrings dirEmptyStrings)(Code) | | Set a new instance of the strings class
Parameters: dirEmptyStrings - new instance |
setFTPFileFactory | public void setFTPFileFactory(FTPFileFactory fileFactory)(Code) | | Override the chosen file factory with a user created one - meaning
that a specific parser has been selected
Parameters: fileFactory - |
setFileNotFoundMessages | public void setFileNotFoundMessages(FileNotFoundStrings fileNotFoundStrings)(Code) | | Set a new instance of the strings class
Parameters: fileNotFoundStrings - new instance |
setForceUniqueNames | public void setForceUniqueNames(boolean forceUnique)(Code) | | Set to true if the STOU command is always to be used when
uploading files, even if a filename is supplied. Normally
STOU is only used if the supplied remote filename is null or
the empty string.
Parameters: forceUnique - true if STOU is always to be used |
setId | public void setId(String id)(Code) | | Set the identifying string for this instance
Parameters: id - identifying string |
setListenOnAllInterfaces | public void setListenOnAllInterfaces(boolean listenOnAll)(Code) | | Listen on all interfaces for active mode transfers (the default).
Parameters: listenOnAll - true if listen on all interfaces, false to listen on the control interface |
setMessageListener | public void setMessageListener(FTPMessageListener listener)(Code) | | Set a listener that handles all FTP messages
Parameters: listener - message listener |
setMonitorInterval | public void setMonitorInterval(long interval)(Code) | | Set the number of bytes transferred between each callback on the
progress monitor
param interval bytes to be transferred before a callback
|
setPORTIP | public void setPORTIP(String IPAddress) throws FTPException(Code) | | We can force PORT to send a fixed IP address, which can be useful with certain
NAT configurations. Must be connected to the remote host to call this method.
Parameters: IPAddress - IP address to force, in 192.168.1.0 form |
setParserLocale | public void setParserLocale(Locale locale)(Code) | | Set the locale for date parsing of dir listings
Parameters: locale - new locale to use |
setParserLocales | public void setParserLocales(Locale[] locales)(Code) | | Set the list of locales to be tried for date parsing of dir listings
Parameters: locales - locales to use |
setProgressMonitorEx | public void setProgressMonitorEx(FTPProgressMonitorEx monitorEx)(Code) | | Set reference to the transfer listener
Parameters: monitorEx - transfer listener |
setRemotePort | public void setRemotePort(int remotePort) throws FTPException(Code) | | Set the control to connect to on the remote server. Can only do this if
not already connected.
Note that this method replaces
FTPClient.setControlPort(int) .
Parameters: remotePort - The port to use. throws: FTPException - Thrown if the client is already connected to the server. |
setServerWakeupInterval | public void setServerWakeupInterval(int interval)(Code) | | Set server wakeup interval in seconds. A value of 0
means it is disabled (the default). This may hang or confuse
the FTP server - use with caution.
Parameters: interval - interval in seconds |
setStrictReturnCodes | public void setStrictReturnCodes(boolean strict)(Code) | | Set strict checking of FTP return codes. If strict
checking is on (the default) code must exactly match the expected
code. If strict checking is off, only the first digit must match.
Parameters: strict - true for strict checking, false for loose checking |
setTimeout | public void setTimeout(int millis) throws IOException(Code) | | Set the SO_TIMEOUT in milliseconds on the underlying socket.
If set this means the socket will block in a read operation
only for this length of time - useful if the FTP sever has
hung, for example. The default is 0, which is an infinite timeout.
Note that for JREs 1.4+, the timeout is also used when first
connecting to the remote host.
Parameters: millis - The length of the timeout, in milliseconds |
setTransferBufferSize | public void setTransferBufferSize(int size)(Code) | | Set the size of the buffers used in writing to and reading from
the data sockets
Parameters: size - new size of buffer in bytes |
setTransferCompleteMessages | public void setTransferCompleteMessages(TransferCompleteStrings transferCompleteStrings)(Code) | | Set a new instance of the strings class
Parameters: transferCompleteStrings - new instance |
site | public boolean site(String command) throws IOException, FTPException(Code) | | Run a site-specific command on the
server. Support for commands is dependent
on the server
Parameters: command - the site command to run true if command ok, false ifcommand not implemented |
toString | public String toString()(Code) | | String representation
|
user | public void user(String user) throws IOException, FTPException(Code) | | Supply the user name to log into an account
on the FTP server. Must be followed by the
password() method - but we allow for no password.
Note that connect() must be called first.
Parameters: user - user name |
validateReply | public void validateReply(FTPReply reply, String expectedReplyCode) throws FTPException(Code) | | Validate an FTPReply
Parameters: reply - reply object Parameters: expectedReplyCode - expected code throws: FTPException - |
validateReply | public void validateReply(FTPReply reply, String[] expectedReplyCodes) throws FTPException(Code) | | Validate an FTPReply
Parameters: reply - reply object Parameters: expectedReplyCodes - expected codes throws: FTPException - |
validateTransfer | public void validateTransfer() throws IOException, FTPException(Code) | | Validate that the put() or get() was successful. This method is not
for general use.
|
|
|