|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object it.sauronsoftware.ftp4j.FTPClient
public class FTPClient
This class implements a FTP client. You can use an instance of this class to connect to a remote FTP site and do FTP operations like directory listing, file upload and download, resume a broken upload/download and so on. The common flow is: create the object, connect to a remote FTP site with the connect() method, authenticate with login(), do anything you need with the contents of the remote site, quit the site with disconnect(). A FTPClient object can handle a connection per time. Once you have used and disconnected a FTPClient object you can use it again to connect another FTP server.
Field Summary | |
---|---|
static int |
MLSD_ALWAYS
The constant for the MLSD policy that causes the client to use always the MLSD command instead of LIST, also if the MLSD command is not explicitly supported by the server (the support is tested with the FEAT command). |
static int |
MLSD_IF_SUPPORTED
The constant for the MLSD policy that causes the client to use the MLSD command instead of LIST, but only if the MLSD command is explicitly supported by the server (the support is tested with the FEAT command). |
static int |
MLSD_NEVER
The constant for the MLSD policy that causes the client to use always the LIST command, also if the MLSD command is explicitly supported by the server (the support is tested with the FEAT command). |
static int |
SECURITY_FTP
The constant for the FTP security level. |
static int |
SECURITY_FTPES
The constant for the FTPES (FTP over explicit TLS/SSL) security level. |
static int |
SECURITY_FTPS
The constant for the FTPS (FTP over implicit TLS/SSL) security level. |
static int |
TYPE_AUTO
The constant for the AUTO file transfer type. |
static int |
TYPE_BINARY
The constant for the BINARY file transfer type. |
static int |
TYPE_TEXTUAL
The constant for the TEXTUAL file transfer type. |
Constructor Summary | |
---|---|
FTPClient()
Builds and initializes the client. |
Method Summary | |
---|---|
void |
abortCurrentConnectionAttempt()
Aborts the current connection attempt. |
void |
abortCurrentDataTransfer(boolean sendAborCommand)
If there's any ongoing data transfer operation, this method aborts it. |
void |
abruptlyCloseCommunication()
This method causes the communication channel to be abruptly closed. |
void |
addCommunicationListener(FTPCommunicationListener listener)
This method adds a FTPCommunicationListener to the object. |
void |
addListParser(FTPListParser listParser)
This method adds a FTPListParser to the object. |
void |
append(java.io.File file)
This method appends the contents of a local file to an existing file on the remote server. |
void |
append(java.io.File file,
FTPDataTransferListener listener)
This method uploads a file to the remote server. |
void |
append(java.lang.String fileName,
java.io.InputStream inputStream,
long streamOffset,
FTPDataTransferListener listener)
This method appends data to an existing file on the remote server. |
void |
changeAccount(java.lang.String account)
Call this method to switch the user current account. |
void |
changeDirectory(java.lang.String path)
This method changes the current working directory. |
void |
changeDirectoryUp()
This method changes the current working directory to the parent one. |
java.lang.String[] |
connect(java.lang.String host)
This method connects the client to the remote FTP host, using the default port value 21 (990 if security level is set to FTPS, see setSecurity(int) ). |
java.lang.String[] |
connect(java.lang.String host,
int port)
This method connects the client to the remote FTP host. |
void |
createDirectory(java.lang.String directoryName)
This method creates a new remote directory in the current working one. |
java.lang.String |
currentDirectory()
This method asks and returns the current working directory. |
void |
deleteDirectory(java.lang.String path)
This method deletes a remote directory. |
void |
deleteFile(java.lang.String path)
This method deletes a remote file. |
void |
disconnect(boolean sendQuitCommand)
This method disconnects from the remote server, optionally performing the QUIT procedure. |
void |
download(java.lang.String remoteFileName,
java.io.File localFile)
This method downloads a remote file from the server to a local file. |
void |
download(java.lang.String remoteFileName,
java.io.File localFile,
FTPDataTransferListener listener)
This method downloads a remote file from the server to a local file. |
void |
download(java.lang.String remoteFileName,
java.io.File localFile,
long restartAt)
This method resumes a download operation from the remote server to a local file. |
void |
download(java.lang.String remoteFileName,
java.io.File localFile,
long restartAt,
FTPDataTransferListener listener)
This method resumes a download operation from the remote server to a local file. |
void |
download(java.lang.String fileName,
java.io.OutputStream outputStream,
long restartAt,
FTPDataTransferListener listener)
This method resumes a download operation from the remote server. |
long |
fileSize(java.lang.String path)
This method asks and returns a file size in bytes. |
long |
getAutoNoopTimeout()
Returns the duration of the auto-noop timeout, in milliseconds. |
java.lang.String |
getCharset()
Returns the name of the charset used to establish textual communications. |
FTPCommunicationListener[] |
getCommunicationListeners()
This method returns a list with all the FTPCommunicationListener
used by the client. |
FTPConnector |
getConnector()
This method returns the connector used to connect the remote host. |
java.lang.String |
getHost()
If the client is connected, it reports the remote host name or address. |
FTPListParser[] |
getListParsers()
This method returns a list with all the FTPListParser used by the
client. |
int |
getMLSDPolicy()
This method returns the value suggesting how the client chooses whether to use or not the MLSD command (RFC 3659) instead of the base LIST command. |
java.lang.String |
getPassword()
If the client is authenticated, it reports the authentication password. |
int |
getPort()
If the client is connected, it reports the remote port number. |
int |
getSecurity()
Returns the security level used by the client in the connection. |
javax.net.ssl.SSLSocketFactory |
getSSLSocketFactory()
Returns the SSL socket factory used to negotiate SSL connections. |
FTPTextualExtensionRecognizer |
getTextualExtensionRecognizer()
This method returns the textual extension recognizer used by the client. |
int |
getType()
This method returns the value suggesting how the client encode and decode the contents during a data transfer. |
java.lang.String |
getUsername()
If the client is authenticated, it reports the authentication username. |
java.lang.String[] |
help()
This method calls the HELP command on the remote server, returning a list of lines with the help contents. |
boolean |
isAuthenticated()
This method tests if this client is authenticated. |
boolean |
isCompressionEnabled()
Checks whether the use of compression is enabled on the client-side. |
boolean |
isCompressionSupported()
Checks whether the connected remote FTP server supports compressed data transfers (uploads, downloads, list operations etc.). |
boolean |
isConnected()
This method tests if this client is connected to a remote FTP server. |
boolean |
isPassive()
This method tests if this client works in passive FTP mode. |
boolean |
isResumeSupported()
Checks whether the connected server explicitly supports resuming of broken data transfers. |
FTPFile[] |
list()
This method lists the entries of the current working directory parsing the reply to a FTP LIST command. |
FTPFile[] |
list(java.lang.String fileSpec)
This method lists the entries of the current working directory parsing the reply to a FTP LIST command. |
java.lang.String[] |
listNames()
This method lists the entries of the current working directory with a FTP NLST command. |
void |
login(java.lang.String username,
java.lang.String password)
This method authenticates the user against the server. |
void |
login(java.lang.String username,
java.lang.String password,
java.lang.String account)
This method authenticates the user against the server. |
void |
logout()
This method performs a logout operation for the current user, leaving the connection open, thus it can be used to start a new user session. |
java.util.Date |
modifiedDate(java.lang.String path)
This method asks and returns the last modification date of a file or directory. |
void |
noop()
This method performs a "noop" operation with the server. |
void |
removeCommunicationListener(FTPCommunicationListener listener)
This method removes a FTPCommunicationListener previously added to the object. |
void |
removeListParser(FTPListParser listParser)
This method removes a FTPListParser previously added to the
object. |
void |
rename(java.lang.String oldPath,
java.lang.String newPath)
This method renames a remote file or directory. |
FTPReply |
sendCustomCommand(java.lang.String command)
This method sends a custom command to the server. |
FTPReply |
sendSiteCommand(java.lang.String command)
This method sends a SITE specific command to the server. |
java.lang.String[] |
serverStatus()
This method returns the remote server status, as the result of a FTP STAT command. |
void |
setAutoNoopTimeout(long autoNoopTimeout)
Enable and disable the auto-noop feature. |
void |
setCharset(java.lang.String charset)
Sets the name of the charset used to establish textual communications. |
void |
setCompressionEnabled(boolean compressionEnabled)
Enables or disables the use of compression during any subsequent data transfer. |
void |
setConnector(FTPConnector connector)
This method sets the connector used to connect the remote host. |
void |
setMLSDPolicy(int mlsdPolicy)
This method lets the user control how the client chooses whether to use or not the MLSD command (RFC 3659) instead of the base LIST command. |
void |
setPassive(boolean passive)
This method enables/disables the use of the passive mode. |
void |
setSecurity(int security)
Sets the security level for the connection. |
void |
setSSLSocketFactory(javax.net.ssl.SSLSocketFactory sslSocketFactory)
Sets the SSL socket factory used to negotiate SSL connections. |
void |
setTextualExtensionRecognizer(FTPTextualExtensionRecognizer textualExtensionRecognizer)
This method sets the textual extension recognizer used by the client. |
void |
setType(int type)
This methods sets how to treat the contents during a file transfer. |
java.lang.String |
toString()
|
void |
upload(java.io.File file)
This method uploads a file to the remote server. |
void |
upload(java.io.File file,
FTPDataTransferListener listener)
This method uploads a file to the remote server. |
void |
upload(java.io.File file,
long restartAt)
This method uploads a file to the remote server. |
void |
upload(java.io.File file,
long restartAt,
FTPDataTransferListener listener)
This method uploads a file to the remote server. |
void |
upload(java.lang.String fileName,
java.io.InputStream inputStream,
long restartAt,
long streamOffset,
FTPDataTransferListener listener)
This method uploads a content to the remote server. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int SECURITY_FTP
public static final int SECURITY_FTPS
public static final int SECURITY_FTPES
public static final int TYPE_AUTO
public static final int TYPE_TEXTUAL
public static final int TYPE_BINARY
public static final int MLSD_IF_SUPPORTED
public static final int MLSD_ALWAYS
public static final int MLSD_NEVER
Constructor Detail |
---|
public FTPClient()
Method Detail |
---|
public FTPConnector getConnector()
public void setConnector(FTPConnector connector)
connector
- The connector used to connect the remote host.DirectConnector
public void setSSLSocketFactory(javax.net.ssl.SSLSocketFactory sslSocketFactory)
sslSocketFactory
- The SSL socket factory used to negotiate SSL connections.public javax.net.ssl.SSLSocketFactory getSSLSocketFactory()
public void setSecurity(int security) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
security
- The security level.
java.lang.IllegalStateException
- If the client is already connected to a server.
java.lang.IllegalArgumentException
- If the supplied security level is not valid.public int getSecurity()
public void setPassive(boolean passive)
passive
- If true the passive mode is enabled.public void setType(int type) throws java.lang.IllegalArgumentException
TYPE_TEXTUAL
means that the data sent or received is
treated as textual information. This implies charset conversion during
the transfer.
TYPE_BINARY
means that the data sent or received is
treated as a binary stream. The data is taken "as is", without any
charset conversion.
TYPE_AUTO
lets the client pick between textual and
binary types, depending on the extension of the file exchanged, using a
FTPTextualExtensionRecognizer instance, which could be set through the
setTextualExtensionRecognizer method. The default recognizer is an
instance of DefaultTextualExtensionRecognizer
.
type
- The type.
java.lang.IllegalArgumentException
- If the supplied type is not valid.setTextualExtensionRecognizer(FTPTextualExtensionRecognizer)
,
DefaultTextualExtensionRecognizer
public int getType()
TYPE_AUTO
,
TYPE_BINARY
and TYPE_TEXTUAL
.public void setMLSDPolicy(int mlsdPolicy) throws java.lang.IllegalArgumentException
MLSD_IF_SUPPORTED
means that the client should use the
MLSD command only if it is explicitly supported by the server.
MLSD_ALWAYS
means that the client should use always the
MLSD command, also if the MLSD command is not explicitly supported by the
server
MLSD_NEVER
means that the client should use always only
the LIST command, also if the MLSD command is explicitly supported by the
server.
The support for the MLSD command is tested by the client after the
connection to the remote server, with the FEAT command.
mlsdPolicy
- The MLSD policy.
java.lang.IllegalArgumentException
- If the supplied MLSD policy value is not valid.public int getMLSDPolicy()
MLSD_IF_SUPPORTED
,
MLSD_ALWAYS
and MLSD_NEVER
.public java.lang.String getCharset()
public void setCharset(java.lang.String charset)
charset
- The name of the charset used to establish textual
communications.public boolean isResumeSupported()
public boolean isCompressionSupported()
setCompressionEnabled(boolean)
.
The returned value is not significant if the client is not connected and
authenticated.
isCompressionEnabled()
public void setCompressionEnabled(boolean compressionEnabled)
isCompressionSupported()
) returned value are
true.
The default value is false.
compressionEnabled
- true to enable the use of compression during any
subsequent file transfer, false to disable the
feature.isCompressionSupported()
public boolean isCompressionEnabled()
isCompressionSupported()
return
true.
isCompressionSupported()
public FTPTextualExtensionRecognizer getTextualExtensionRecognizer()
DefaultTextualExtensionRecognizer
.
DefaultTextualExtensionRecognizer
public void setTextualExtensionRecognizer(FTPTextualExtensionRecognizer textualExtensionRecognizer)
DefaultTextualExtensionRecognizer
.
You can plug your own by implementing the
FTPTextualExtensionRecognizer
interface. For your convenience the
ftp4j gives you another FTPTextualExtensionRecognizer implementation,
which is ParametricTextualExtensionRecognizer
.
textualExtensionRecognizer
- The textual extension recognizer used by the client.DefaultTextualExtensionRecognizer
,
ParametricTextualExtensionRecognizer
public boolean isAuthenticated()
public boolean isConnected()
public boolean isPassive()
public java.lang.String getHost()
public int getPort()
public java.lang.String getPassword()
public java.lang.String getUsername()
public void setAutoNoopTimeout(long autoNoopTimeout)
autoNoopTimeout
- The duration of the auto-noop timeout, in milliseconds. If 0
or less, the auto-noop feature is disabled.public long getAutoNoopTimeout()
public void addCommunicationListener(FTPCommunicationListener listener)
listener
- The listener.public void removeCommunicationListener(FTPCommunicationListener listener)
listener
- The listener to be removed.public FTPCommunicationListener[] getCommunicationListeners()
FTPCommunicationListener
used by the client.
public void addListParser(FTPListParser listParser)
FTPListParser
to the object.
listParser
- The list parser.public void removeListParser(FTPListParser listParser)
FTPListParser
previously added to the
object.
listParser
- The list parser to be removed.public FTPListParser[] getListParsers()
FTPListParser
used by the
client.
public java.lang.String[] connect(java.lang.String host) throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException
setSecurity(int)
).
host
- The hostname of the remote server.
java.lang.IllegalStateException
- If the client is already connected to a remote host.
java.io.IOException
- If an I/O occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the server refuses the connection.public java.lang.String[] connect(java.lang.String host, int port) throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException
host
- The host name or address of the remote server.port
- The port listened by the remote server.
java.lang.IllegalStateException
- If the client is already connected to a remote host.
java.io.IOException
- If an I/O occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the server refuses the connection.public void abortCurrentConnectionAttempt()
IOException
.
public void disconnect(boolean sendQuitCommand) throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException
sendQuitCommand
- If true the QUIT procedure with the server will be performed,
otherwise the connection is abruptly closed by the client
without sending any advice to the server.
java.lang.IllegalStateException
- If the client is not connected to a remote host.
java.io.IOException
- If an I/O occurs (can be thrown only if sendQuitCommand is
true).
FTPIllegalReplyException
- If the server replies in an illegal way (can be thrown only
if sendQuitCommand is true).
FTPException
- If the server refuses the QUIT command (can be thrown only if
sendQuitCommand is true).public void abruptlyCloseCommunication()
disconnect(boolean)
public void login(java.lang.String username, java.lang.String password) throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException
username
- The username.password
- The password (if none set it to null).
java.lang.IllegalStateException
- If the client is not connected. Call the connect() method
before!
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If login fails.public void login(java.lang.String username, java.lang.String password, java.lang.String account) throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException
username
- The username.password
- The password (if none set it to null).account
- The account (if none set it to null). Be careful: some servers
don't implement this feature.
java.lang.IllegalStateException
- If the client is not connected. Call the connect() method
before!
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If login fails.public void logout() throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.public void noop() throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If login fails.public FTPReply sendCustomCommand(java.lang.String command) throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException
command
- The command line.
java.lang.IllegalStateException
- If this client is not connected.
java.io.IOException
- If a I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.public FTPReply sendSiteCommand(java.lang.String command) throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException
command
- The site command.
java.lang.IllegalStateException
- If this client is not connected.
java.io.IOException
- If a I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.public void changeAccount(java.lang.String account) throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException
account
- The account.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If login fails.public java.lang.String currentDirectory() throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.public void changeDirectory(java.lang.String path) throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException
path
- The path to the new working directory.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.public void changeDirectoryUp() throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.public java.util.Date modifiedDate(java.lang.String path) throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException
path
- The path to the file or the directory.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.public long fileSize(java.lang.String path) throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException
path
- The path to the file.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.public void rename(java.lang.String oldPath, java.lang.String newPath) throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException
client.rename("oldname", "newname"); // This one renames
client.rename("the/old/path/oldname", "/a/new/path/newname"); // This one moves
oldPath
- The current path of the file (or directory).newPath
- The new path for the file (or directory).
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.public void deleteFile(java.lang.String path) throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException
path
- The path to the file.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.public void deleteDirectory(java.lang.String path) throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException
path
- The path to the directory.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.public void createDirectory(java.lang.String directoryName) throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException
directoryName
- The name of the new directory.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.public java.lang.String[] help() throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.public java.lang.String[] serverStatus() throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.public FTPFile[] list(java.lang.String fileSpec) throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException, FTPListParseException
fileSpec
- A file filter string. Depending on the server implementation,
wildcard characters could be accepted.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.
FTPDataTransferException
- If a I/O occurs in the data transfer connection. If you
receive this exception the transfer failed, but the main
connection with the remote FTP server is in theory still
working.
FTPAbortedException
- If operation is aborted by another thread.
FTPListParseException
- If none of the registered parsers can handle the response
sent by the server.FTPListParser
,
addListParser(FTPListParser)
,
getListParsers()
,
abortCurrentDataTransfer(boolean)
,
listNames()
public FTPFile[] list() throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException, FTPListParseException
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.
FTPDataTransferException
- If a I/O occurs in the data transfer connection. If you
receive this exception the transfer failed, but the main
connection with the remote FTP server is in theory still
working.
FTPAbortedException
- If operation is aborted by another thread.
FTPListParseException
- If none of the registered parsers can handle the response
sent by the server.FTPListParser
,
addListParser(FTPListParser)
,
getListParsers()
,
abortCurrentDataTransfer(boolean)
,
listNames()
public java.lang.String[] listNames() throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException, FTPListParseException
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.
FTPDataTransferException
- If a I/O occurs in the data transfer connection. If you
receive this exception the transfer failed, but the main
connection with the remote FTP server is in theory still
working.
FTPAbortedException
- If operation is aborted by another thread.
FTPListParseException
- If none of the registered parsers can handle the response
sent by the server.abortCurrentDataTransfer(boolean)
,
list()
public void upload(java.io.File file) throws java.lang.IllegalStateException, java.io.FileNotFoundException, java.io.IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException
file
- The file to upload.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.FileNotFoundException
- If the supplied file cannot be found.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.
FTPDataTransferException
- If a I/O occurs in the data transfer connection. If you
receive this exception the transfer failed, but the main
connection with the remote FTP server is in theory still
working.
FTPAbortedException
- If operation is aborted by another thread.abortCurrentDataTransfer(boolean)
public void upload(java.io.File file, FTPDataTransferListener listener) throws java.lang.IllegalStateException, java.io.FileNotFoundException, java.io.IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException
file
- The file to upload.listener
- The listener for the operation. Could be null.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.FileNotFoundException
- If the supplied file cannot be found.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.
FTPDataTransferException
- If a I/O occurs in the data transfer connection. If you
receive this exception the transfer failed, but the main
connection with the remote FTP server is in theory still
working.
FTPAbortedException
- If operation is aborted by another thread.abortCurrentDataTransfer(boolean)
public void upload(java.io.File file, long restartAt) throws java.lang.IllegalStateException, java.io.FileNotFoundException, java.io.IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException
file
- The file to upload.restartAt
- The restart point (number of bytes already uploaded). Use
isResumeSupported()
to check if the server
supports resuming of broken data transfers.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.FileNotFoundException
- If the supplied file cannot be found.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.
FTPDataTransferException
- If a I/O occurs in the data transfer connection. If you
receive this exception the transfer failed, but the main
connection with the remote FTP server is in theory still
working.
FTPAbortedException
- If operation is aborted by another thread.abortCurrentDataTransfer(boolean)
public void upload(java.io.File file, long restartAt, FTPDataTransferListener listener) throws java.lang.IllegalStateException, java.io.FileNotFoundException, java.io.IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException
file
- The file to upload.restartAt
- The restart point (number of bytes already uploaded). Use
isResumeSupported()
to check if the server
supports resuming of broken data transfers.listener
- The listener for the operation. Could be null.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.FileNotFoundException
- If the supplied file cannot be found.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.
FTPDataTransferException
- If a I/O occurs in the data transfer connection. If you
receive this exception the transfer failed, but the main
connection with the remote FTP server is in theory still
working.
FTPAbortedException
- If operation is aborted by another thread.abortCurrentDataTransfer(boolean)
public void upload(java.lang.String fileName, java.io.InputStream inputStream, long restartAt, long streamOffset, FTPDataTransferListener listener) throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException
fileName
- The name of the remote file.inputStream
- The source of data.restartAt
- The restart point (number of bytes already uploaded). Use
isResumeSupported()
to check if the server
supports resuming of broken data transfers.streamOffset
- The offset to skip in the stream.listener
- The listener for the operation. Could be null.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.
FTPDataTransferException
- If a I/O occurs in the data transfer connection. If you
receive this exception the transfer failed, but the main
connection with the remote FTP server is in theory still
working.
FTPAbortedException
- If operation is aborted by another thread.abortCurrentDataTransfer(boolean)
public void append(java.io.File file) throws java.lang.IllegalStateException, java.io.FileNotFoundException, java.io.IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException
file
- The local file whose contents will be appended to the remote
file.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.FileNotFoundException
- If the supplied file cannot be found.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.
FTPDataTransferException
- If a I/O occurs in the data transfer connection. If you
receive this exception the transfer failed, but the main
connection with the remote FTP server is in theory still
working.
FTPAbortedException
- If operation is aborted by another thread.abortCurrentDataTransfer(boolean)
public void append(java.io.File file, FTPDataTransferListener listener) throws java.lang.IllegalStateException, java.io.FileNotFoundException, java.io.IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException
file
- The local file whose contents will be appended to the remote
file.listener
- The listener for the operation. Could be null.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.FileNotFoundException
- If the supplied file cannot be found.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.
FTPDataTransferException
- If a I/O occurs in the data transfer connection. If you
receive this exception the transfer failed, but the main
connection with the remote FTP server is in theory still
working.
FTPAbortedException
- If operation is aborted by another thread.abortCurrentDataTransfer(boolean)
public void append(java.lang.String fileName, java.io.InputStream inputStream, long streamOffset, FTPDataTransferListener listener) throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException
fileName
- The name of the remote file.inputStream
- The source of data.streamOffset
- The offset to skip in the stream.listener
- The listener for the operation. Could be null.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.
FTPDataTransferException
- If a I/O occurs in the data transfer connection. If you
receive this exception the transfer failed, but the main
connection with the remote FTP server is in theory still
working.
FTPAbortedException
- If operation is aborted by another thread.abortCurrentDataTransfer(boolean)
public void download(java.lang.String remoteFileName, java.io.File localFile) throws java.lang.IllegalStateException, java.io.FileNotFoundException, java.io.IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException
remoteFileName
- The name of the file to download.localFile
- The local file.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.FileNotFoundException
- If the supplied file cannot be found.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.
FTPDataTransferException
- If a I/O occurs in the data transfer connection. If you
receive this exception the transfer failed, but the main
connection with the remote FTP server is in theory still
working.
FTPAbortedException
- If operation is aborted by another thread.abortCurrentDataTransfer(boolean)
public void download(java.lang.String remoteFileName, java.io.File localFile, FTPDataTransferListener listener) throws java.lang.IllegalStateException, java.io.FileNotFoundException, java.io.IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException
remoteFileName
- The name of the file to download.localFile
- The local file.listener
- The listener for the operation. Could be null.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.FileNotFoundException
- If the supplied file cannot be found.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.
FTPDataTransferException
- If a I/O occurs in the data transfer connection. If you
receive this exception the transfer failed, but the main
connection with the remote FTP server is in theory still
working.
FTPAbortedException
- If operation is aborted by another thread.abortCurrentDataTransfer(boolean)
public void download(java.lang.String remoteFileName, java.io.File localFile, long restartAt) throws java.lang.IllegalStateException, java.io.FileNotFoundException, java.io.IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException
remoteFileName
- The name of the file to download.localFile
- The local file.restartAt
- The restart point (number of bytes already downloaded). Use
isResumeSupported()
to check if the server
supports resuming of broken data transfers.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.FileNotFoundException
- If the supplied file cannot be found.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.
FTPDataTransferException
- If a I/O occurs in the data transfer connection. If you
receive this exception the transfer failed, but the main
connection with the remote FTP server is in theory still
working.
FTPAbortedException
- If operation is aborted by another thread.abortCurrentDataTransfer(boolean)
public void download(java.lang.String remoteFileName, java.io.File localFile, long restartAt, FTPDataTransferListener listener) throws java.lang.IllegalStateException, java.io.FileNotFoundException, java.io.IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException
remoteFileName
- The name of the file to download.localFile
- The local file.restartAt
- The restart point (number of bytes already downloaded). Use
isResumeSupported()
to check if the server
supports resuming of broken data transfers.listener
- The listener for the operation. Could be null.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.FileNotFoundException
- If the supplied file cannot be found.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.
FTPDataTransferException
- If a I/O occurs in the data transfer connection. If you
receive this exception the transfer failed, but the main
connection with the remote FTP server is in theory still
working.
FTPAbortedException
- If operation is aborted by another thread.abortCurrentDataTransfer(boolean)
public void download(java.lang.String fileName, java.io.OutputStream outputStream, long restartAt, FTPDataTransferListener listener) throws java.lang.IllegalStateException, java.io.IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException
fileName
- The name of the remote file.outputStream
- The destination stream of data read during the download.restartAt
- The restart point (number of bytes already downloaded). Use
isResumeSupported()
to check if the server
supports resuming of broken data transfers.listener
- The listener for the operation. Could be null.
java.lang.IllegalStateException
- If the client is not connected or not authenticated.
java.io.IOException
- If an I/O error occurs.
FTPIllegalReplyException
- If the server replies in an illegal way.
FTPException
- If the operation fails.
FTPDataTransferException
- If a I/O occurs in the data transfer connection. If you
receive this exception the transfer failed, but the main
connection with the remote FTP server is in theory still
working.
FTPAbortedException
- If operation is aborted by another thread.abortCurrentDataTransfer(boolean)
public void abortCurrentDataTransfer(boolean sendAborCommand) throws java.io.IOException, FTPIllegalReplyException
sendAborCommand
- If true the client will negotiate the abort procedure with the
server, through the standard FTP ABOR command. Otherwise the
open data transfer connection will be closed without any
advise has sent to the server.
java.io.IOException
- If the ABOR command cannot be sent due to any I/O error. This
could happen only if force is false.
FTPIllegalReplyException
- If the server reply to the ABOR command is illegal. This
could happen only if force is false.public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |