public class FTPClient extends java.lang.Object implements FTPClientInterface
Modifier and Type | Field and Description |
---|---|
static byte |
CARRIAGE_RETURN
Used for ASCII translation
|
protected FTPControlSocket |
control
Socket responsible for controlling
the connection
|
protected java.lang.String |
controlEncoding
Encoding used on control socket
|
protected int |
controlPort
Control port number.
|
static java.lang.String |
cvsId
Revision control id
|
protected com.enterprisedt.net.ftp.internal.FTPDataSocket |
data
Socket responsible for transferring
the data
|
protected DataChannelCallback |
dataChannelCallback
Pasv callback method
|
protected int |
dataReceiveBufferSize
Size of data socket's receive buffer
|
protected int |
dataSendBufferSize
Size of data socket's send buffer
|
static int |
DEFAULT_BUFFER_SIZE
Default transfer buffer size
|
static java.lang.String |
DEFAULT_ENCODING
Default encoding used for control data
|
static java.util.Locale[] |
DEFAULT_LISTING_LOCALES
Default locales
|
static int |
DEFAULT_MONITOR_INTERVAL
Default byte interval for transfer monitor
|
static int |
DEFAULT_RETRY_COUNT
Default number of retries for file transfers
|
static int |
DEFAULT_RETRY_DELAY
Default retry delay in milliseconds
|
static int |
DEFAULT_TCP_BUFFER_SIZE
Default SO_SNDBUF and SO_RCVBUF size
|
static int |
DEFAULT_TIMEOUT
Default timeout
|
protected boolean |
detectTransferMode
If true, filetypes are autodetected and transfer mode changed to binary/ASCII as
required
|
protected DirectoryEmptyStrings |
dirEmptyStrings
Matcher for directory empty
|
protected boolean |
fileLockingEnabled
If true, file locking is used on local downloaded files to prevent
other processes corrupting them
|
protected FileNotFoundStrings |
fileNotFoundStrings
Matcher for permission denied
|
static byte[] |
FTP_LINE_SEPARATOR
Used for ASCII translation
|
protected java.lang.String |
id
Id of instance
|
protected FTPReply |
lastReply
Holds the last reply from the server on the control socket
|
protected FTPReply |
lastValidReply
Holds the last valid reply from the server on the control socket
|
static byte |
LINE_FEED
Used for ASCII translation
|
static byte[] |
LINE_SEPARATOR
Local line separator
|
protected FTPMessageListener |
messageListener
Message listener
|
protected FTPProgressMonitor |
monitor
Progress monitor
|
protected FTPProgressMonitorEx |
monitorEx
File transfer listener
|
protected long |
monitorInterval
Bytes transferred in between monitor callbacks
|
protected java.lang.String |
password
Password cached
|
protected java.net.InetAddress |
remoteAddr
Address of the remote server.
|
protected java.lang.String |
remoteHost
Name/IP of remote host
|
protected int |
serverWakeupInterval
Interval in seconds in between server wakeups.
|
protected BandwidthThrottler |
throttler
Threshold for throttling
|
protected int |
timeout
Socket timeout for both data and control.
|
protected int |
transferBufferSize
Size of transfer buffers
|
protected TransferCompleteStrings |
transferCompleteStrings
Matcher for transfer complete
|
protected FTPTransferType |
transferType
Record of the transfer type - make the default ASCII
|
protected boolean |
useNOOP
NOOP supported?
|
protected java.lang.String |
user
Username cached
|
Constructor and Description |
---|
FTPClient()
Default constructor should now always be used together with setter methods
in preference to other constructors (now deprecated).
|
FTPClient(java.net.InetAddress remoteAddr)
Deprecated.
use setter methods to set properties
|
FTPClient(java.net.InetAddress remoteAddr,
int controlPort)
Deprecated.
use setter methods to set properties
|
FTPClient(java.net.InetAddress remoteAddr,
int controlPort,
int timeout)
Deprecated.
use setter methods to set properties
|
FTPClient(java.net.InetAddress remoteAddr,
int controlPort,
int timeout,
java.lang.String encoding)
Deprecated.
use setter methods to set properties
|
FTPClient(java.lang.String remoteHost)
Deprecated.
use setter methods to set properties
|
FTPClient(java.lang.String remoteHost,
int controlPort)
Deprecated.
use setter methods to set properties
|
FTPClient(java.lang.String remoteHost,
int controlPort,
int timeout)
Deprecated.
use setter methods to set properties
|
FTPClient(java.lang.String remoteHost,
int controlPort,
int timeout,
java.lang.String encoding)
Deprecated.
use setter methods to set properties
|
Modifier and Type | Method and Description |
---|---|
protected void |
abort()
Abort the current action
|
void |
account(java.lang.String accountInfo)
Supply account information string to the server.
|
void |
cancelResume()
Cancel the resume.
|
void |
cancelTransfer()
Cancels the current transfer.
|
void |
cdup()
Change the remote working directory to
the parent directory
|
void |
chdir(java.lang.String dir)
Change the remote working directory to
that supplied
|
protected void |
checkConnection(boolean shouldBeConnected)
Checks if the client has connected to the server and throws an exception if it hasn't.
|
protected FTPTransferType |
chooseTransferMode(java.lang.String filename)
Switch the transfer mode if requested and if necessary
|
static void |
clearSOCKS()
Clear SOCKS settings.
|
protected void |
closeDataSocket(java.io.InputStream stream)
Close stream for data socket.
|
protected void |
closeDataSocket(java.io.OutputStream stream)
Close stream for data socket
|
protected void |
configureDataSocket() |
void |
connect()
Connects to the server at the address and port number defined
in the constructor.
|
boolean |
connected()
Is this client connected?
|
protected void |
createDataSocket()
Set up the data socket
|
void |
debugResponses(boolean on)
Deprecated.
use the Logger class to switch debugging on and off
|
void |
delete(java.lang.String remoteFile)
Delete the specified remote file
|
java.lang.String[] |
dir()
List current directory's contents as an array of strings of
filenames.
|
java.lang.String[] |
dir(java.lang.String dirname)
List a directory's contents as an array of strings of filenames.
|
java.lang.String[] |
dir(java.lang.String dirname,
boolean full)
List a directory's contents as an array of strings.
|
FTPFile[] |
dirDetails(java.lang.String dirname)
List a directory's contents as an array of FTPFile objects.
|
void |
dirDetails(java.lang.String dirname,
DirectoryListCallback lister)
List a directory's contents via a callback.
|
FTPFile[] |
dirDetailsM(java.lang.String dirname)
Uses the MLSD command to find out details about the
named directory.
|
java.lang.String |
executeCommand(java.lang.String command)
Request that the remote server execute the literal command supplied.
|
boolean |
exists(java.lang.String remoteFile)
Deprecated.
Use existsFile(String).
|
boolean |
existsDirectory(java.lang.String remoteDirectory)
Use to find out if a directory exists or not.
|
boolean |
existsFile(java.lang.String remoteFile)
Use to find out if a file exists or not.
|
java.lang.String[] |
features()
Get the server supplied features
|
FTPFile |
fileDetails(java.lang.String name)
Uses the MLST command to find out details about the
named file.
|
protected void |
forceResumeOff()
Force the resume flag off.
|
void |
get(java.io.OutputStream destStream,
java.lang.String remoteFile)
Get data from the FTP server.
|
byte[] |
get(java.lang.String remoteFile)
Get data from the FTP server.
|
void |
get(java.lang.String localPath,
java.lang.String remoteFile)
Get data from the FTP server.
|
int |
getActiveHighPort()
Get the upper limit of the port range for active mode.
|
java.lang.String |
getActiveIPAddress()
Get the active IP address that is set.
|
int |
getActiveLowPort()
Get the lower limit of the port range for active mode.
|
static java.lang.String |
getBuildTimestamp()
Get the build timestamp
|
FTPConnectMode |
getConnectMode() |
java.lang.String |
getControlEncoding()
Get the encoding used for the control connection
|
int |
getControlPort()
Deprecated.
Use
FTPClientInterface.getRemotePort() instead. |
int |
getDataReceiveBufferSize()
Deprecated.
|
int |
getDataSendBufferSize()
Deprecated.
|
int |
getDeleteCount()
Get the number of files deleted since the count was
reset
|
boolean |
getDetectTransferMode()
Get the detect transfer mode
|
DirectoryEmptyStrings |
getDirectoryEmptyMessages()
Get class that holds fragments of server messages that indicate a
directory is empty.
|
int |
getDownloadCount()
Get the number of files downloaded since the count was
reset
|
boolean |
getFileLockingEnabled()
Determine if file locking on local downloaded files is being used or not.
|
FileNotFoundStrings |
getFileNotFoundMessages()
Get class that holds fragments of server messages that indicate a file was
not found.
|
java.lang.String |
getId()
Get the identifying string for this instance
|
protected java.io.InputStream |
getInputStream()
Get the data input stream.
|
FTPReply |
getLastReply()
Gets the last reply from the server, whether valid or not
|
FTPReply |
getLastValidReply()
Gets the latest valid reply from the server
|
boolean |
getListenOnAllInterfaces()
Are we listening on all interfaces in active mode, which is the default?
|
FTPMessageListener |
getMessageListener() |
long |
getMonitorInterval()
Get the bytes transferred between each callback on the
progress monitor
|
int |
getNetworkBufferSize()
Get the size of the network buffers (SO_SNDBUF
and SO_RCVBUF).
|
protected java.io.OutputStream |
getOutputStream()
Get the data input stream.
|
FTPProgressMonitor |
getProgressMonitor()
Get the reference to the progress monitor
|
FTPProgressMonitorEx |
getProgressMonitorEx()
Get reference to the transfer listener
|
java.net.InetAddress |
getRemoteAddr() |
java.lang.String |
getRemoteHost()
Returns the IP address or name of the remote host.
|
int |
getRemotePort()
Returns the control-port being connected to on the remote server.
|
int |
getRetryCount()
Get the retry count for retrying file transfers.
|
int |
getRetryDelay()
Get the retry delay between retry attempts, in milliseconds.
|
int |
getServerWakeupInterval()
Get server wakeup interval in seconds.
|
int |
getTimeout()
Get the TCP timeout
|
int |
getTransferBufferSize()
Get the size of the buffers used in writing to and reading from
the data sockets
|
TransferCompleteStrings |
getTransferCompleteMessages()
Get class that holds fragments of server messages that indicate a transfer completed.
|
FTPTransferType |
getType()
Get the current transfer type
|
int |
getUploadCount()
Get the number of files uploaded since the count was
reset
|
static int[] |
getVersion()
Get the version of edtFTPj
|
java.lang.String |
help(java.lang.String command)
Get the help text for the specified command
|
protected void |
initGet(java.lang.String remoteFile)
Request to the server that the get is set up
|
protected void |
initialize(FTPControlSocket control)
Set the control socket explicitly
|
protected java.lang.String |
initPut(java.lang.String remoteFile,
boolean append)
Request the server to set up the put
|
static void |
initSOCKS(java.lang.String port,
java.lang.String host)
Set up SOCKS v4/v5 proxy settings.
|
static void |
initSOCKSAuthentication(java.lang.String username,
java.lang.String password)
Set up SOCKS username and password for SOCKS username/password
authentication.
|
boolean |
isAutoPassiveIPSubstitution()
Is automatic substitution of the remote host IP set to
be on for passive mode connections?
|
boolean |
isDeleteOnFailure()
If true, delete partially written files when exceptions are thrown
during a download
|
boolean |
isStrictReturnCodes()
Determine if strict checking of return codes is switched on.
|
boolean |
isTransferCancelled()
Has the current transfer been cancelled?
|
void |
keepAlive()
Tries to keep the current connection alive by
sending an innocuous command to signal that the
client is still active
|
java.lang.String |
list(java.lang.String dirname)
Deprecated.
As of FTP 1.1, replaced by
dir(String) |
java.lang.String |
list(java.lang.String dirname,
boolean full)
Deprecated.
As of FTP 1.1, replaced by
dir(String,boolean) |
void |
login(java.lang.String user,
java.lang.String password)
Login into an account on the FTP server.
|
void |
login(java.lang.String user,
java.lang.String password,
java.lang.String accountInfo)
Login into an account on the FTP server.
|
void |
mkdir(java.lang.String dir)
Create the specified remote working directory
|
java.util.Date |
modtime(java.lang.String remoteFile)
Get modification time for a remote file.
|
void |
noOp()
Send the NOOP message
|
void |
noOperation()
Send a "no operation" message that does nothing.
|
void |
password(java.lang.String password)
Supplies the password for a previously supplied
username to log into the FTP server.
|
protected void |
postTransferChecks(byte[] localBytes,
java.lang.String remotePath,
FTPTransferType transferType,
boolean append)
Can be overridden by subclasses to do any necessary post transfer
checking.
|
protected void |
postTransferChecks(java.lang.String localPath,
java.lang.String remotePath,
FTPTransferType transferType,
boolean append)
Can be overridden by subclasses to do any necessary post transfer
checking.
|
java.lang.String |
put(byte[] bytes,
java.lang.String remoteFile)
Put data onto the FTP server.
|
java.lang.String |
put(byte[] bytes,
java.lang.String remoteFile,
boolean append)
Put data onto the FTP server.
|
java.lang.String |
put(java.io.InputStream srcStream,
java.lang.String remoteFile)
Put a stream of data onto the FTP server.
|
java.lang.String |
put(java.io.InputStream srcStream,
java.lang.String remoteFile,
boolean append)
Put a stream of data onto the FTP server.
|
java.lang.String |
put(java.lang.String localPath,
java.lang.String remoteFile)
Put a local file onto the FTP server.
|
java.lang.String |
put(java.lang.String localPath,
java.lang.String remoteFile,
boolean append)
Put a local file onto the FTP server.
|
java.lang.String |
pwd()
Get the current remote working directory
|
void |
quit()
Quit the FTP session
|
void |
quitImmediately()
Quit the FTP session immediately.
|
java.lang.String |
quote(java.lang.String command)
Issue arbitrary ftp commands to the FTP server.
|
java.lang.String |
quote(java.lang.String command,
java.lang.String[] validCodes)
Issue arbitrary ftp commands to the FTP server.
|
protected int |
readChar(java.io.LineNumberReader in)
Attempts to read a single character from the given
InputStream . |
int |
readChunk(java.io.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. |
int |
readChunk(java.io.BufferedInputStream in,
byte[] chunk,
int offset,
int chunksize)
Attempts to read a specified number of bytes from the given
InputStream and place it in the given byte-array. |
protected java.lang.String |
readLine(java.io.LineNumberReader in)
Attempts to read a single line from the given
InputStream . |
protected void |
reconnect(java.lang.String cwd)
Reconnect to the server
|
void |
rename(java.lang.String from,
java.lang.String to)
Rename a file or directory
|
void |
resetDeleteCount()
Reset the count of deleted files to zero.
|
void |
resetDownloadCount()
Reset the count of downloaded files to zero.
|
void |
resetTransferMode(FTPTransferType previousType)
Reset the transfer mode back to what it should be, if
it has changed.
|
void |
resetUploadCount()
Reset the count of uploaded files to zero.
|
void |
restart(long size)
Issue the RESTart command to the remote server.
|
void |
resume()
Make the next file transfer (put or get) resume.
|
void |
resumeNextDownload(long offset)
Make the next download resume at a specific point.
|
void |
rmdir(java.lang.String dir)
Delete the specified remote working directory
|
FTPReply |
sendCommand(java.lang.String command)
Send a command to the server and get the reply
|
void |
sendServerWakeup()
Wake up the server during a transfer to prevent a
timeout from occuring.
|
void |
setActiveIPAddress(java.lang.String activeIP)
We can force PORT to send a fixed IP address, which can be useful with certain
NAT configurations.
|
void |
setActivePortRange(int lowest,
int highest)
Force a certain range of ports to be used in active mode.
|
void |
setAutoPassiveIPSubstitution(boolean autoPassiveIPSubstitution)
Set automatic substitution of the remote host IP on if
in passive mode.
|
void |
setConnectMode(FTPConnectMode mode)
Set the connect mode
|
void |
setControlEncoding(java.lang.String controlEncoding)
Set the control socket's encoding.
|
void |
setControlPort(int controlPort)
Deprecated.
Use
FTPClientInterface.setRemotePort(int) instead. |
void |
setDataChannelCallback(DataChannelCallback callback)
Set the data channel callback, which notifies of the
ip and port number to be connected to, and gives an opportunity
to modify these values
|
void |
setDataReceiveBufferSize(int size)
Deprecated.
|
void |
setDataSendBufferSize(int size)
Deprecated.
|
void |
setDeleteOnFailure(boolean deleteOnFailure)
Switch on or off the automatic deletion of partially written files
that are left when an exception is thrown during a download
|
void |
setDetectTransferMode(boolean detectTransferMode)
Set autodetect of filetypes on or off.
|
void |
setDirectoryEmptyMessages(DirectoryEmptyStrings dirEmptyStrings)
Set a new instance of the strings class
|
void |
setFileLockingEnabled(boolean lockingEnabled)
Set file locking to enabled or disabled.
|
void |
setFileNotFoundMessages(FileNotFoundStrings fileNotFoundStrings)
Set a new instance of the strings class
|
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.
|
void |
setFTPFileFactory(FTPFileFactory fileFactory)
Override the chosen file factory with a user created one - meaning
that a specific parser has been selected
|
void |
setId(java.lang.String id)
Set the identifying string for this instance
|
void |
setListenOnAllInterfaces(boolean listenOnAll)
Listen on all interfaces for active mode transfers (the default).
|
void |
setMessageListener(FTPMessageListener listener)
Set a listener that handles all FTP messages
|
void |
setModTime(java.lang.String remoteFile,
java.util.Date modTime)
Set the last modified time (UTC) for the supplied file.
|
void |
setMonitorInterval(long interval)
Set the number of bytes transferred between each callback on the
progress monitor
param interval bytes to be transferred before a callback
|
void |
setNetworkBufferSize(int networkBufferSize)
Set the size of the network buffers (SO_SNDBUF
and SO_RCVBUF).
|
void |
setParserLocale(java.util.Locale locale)
Deprecated.
@see FTPClient#setParserLocales(Locale[])
|
void |
setParserLocales(java.util.Locale[] locales)
Set the list of locales to be tried for date parsing of dir listings
|
void |
setPORTIP(java.lang.String IPAddress)
Deprecated.
|
void |
setProgressMonitor(FTPProgressMonitor monitor)
Set a progress monitor for callbacks.
|
void |
setProgressMonitor(FTPProgressMonitor monitor,
long interval)
Set a progress monitor for callbacks.
|
void |
setProgressMonitorEx(FTPProgressMonitorEx monitorEx)
Set reference to the transfer listener
|
void |
setRemoteAddr(java.net.InetAddress remoteAddr)
Set the remote address
|
void |
setRemoteHost(java.lang.String remoteHost)
Set the IP address or name of the remote host
This may only be done if the client is not already connected to the server.
|
void |
setRemotePort(int remotePort)
Set the control to connect to on the remote server.
|
void |
setRetryCount(int retryCount)
Set the retry count for retrying file transfers.
|
void |
setRetryDelay(int retryDelay)
Set the retry delay between retry attempts, in milliseconds
|
void |
setServerWakeupInterval(int interval)
Set server wakeup interval in seconds.
|
void |
setStrictReturnCodes(boolean strict)
Set strict checking of FTP return codes.
|
void |
setTimeout(int millis)
Set the SO_TIMEOUT in milliseconds on the underlying socket.
|
void |
setTransferBufferSize(int size)
Set the size of the buffers used in writing to and reading from
the data sockets
|
void |
setTransferCompleteMessages(TransferCompleteStrings transferCompleteStrings)
Set a new instance of the strings class
|
void |
setType(FTPTransferType type)
Set the transfer type
|
boolean |
site(java.lang.String command)
Run a site-specific command on the
server.
|
long |
size(java.lang.String remoteFile)
Get the size of a remote file.
|
java.lang.String |
stat()
Sends stat message to enquire about the status of a
transfer.
|
java.lang.String |
system()
Get the type of the OS at the server
|
java.lang.String |
toString()
String representation
|
void |
user(java.lang.String user)
Supply the user name to log into an account
on the FTP server.
|
void |
validateReply(FTPReply reply,
java.lang.String expectedReplyCode)
Validate an FTPReply
|
void |
validateReply(FTPReply reply,
java.lang.String[] expectedReplyCodes)
Validate an FTPReply
|
void |
validateTransfer()
Validate that the put() or get() was successful.
|
protected void |
validateTransferOnError(java.io.IOException ex)
Validate a transfer when an error has occurred on the data channel.
|
public static java.lang.String cvsId
public static final int DEFAULT_MONITOR_INTERVAL
public static final int DEFAULT_BUFFER_SIZE
public static final int DEFAULT_TIMEOUT
public static final int DEFAULT_RETRY_COUNT
public static final int DEFAULT_RETRY_DELAY
public static final int DEFAULT_TCP_BUFFER_SIZE
public static final java.lang.String DEFAULT_ENCODING
public static byte[] LINE_SEPARATOR
public static final byte CARRIAGE_RETURN
public static final byte LINE_FEED
public static final byte[] FTP_LINE_SEPARATOR
public static java.util.Locale[] DEFAULT_LISTING_LOCALES
protected FTPControlSocket control
protected com.enterprisedt.net.ftp.internal.FTPDataSocket data
protected int timeout
protected int serverWakeupInterval
protected java.net.InetAddress remoteAddr
protected java.lang.String remoteHost
protected java.lang.String id
protected int controlPort
protected java.lang.String controlEncoding
protected DirectoryEmptyStrings dirEmptyStrings
protected TransferCompleteStrings transferCompleteStrings
protected FileNotFoundStrings fileNotFoundStrings
protected boolean detectTransferMode
protected boolean fileLockingEnabled
protected long monitorInterval
protected int transferBufferSize
protected int dataReceiveBufferSize
protected int dataSendBufferSize
protected FTPProgressMonitor monitor
protected FTPMessageListener messageListener
protected FTPProgressMonitorEx monitorEx
protected FTPTransferType transferType
protected FTPReply lastValidReply
protected FTPReply lastReply
protected java.lang.String user
protected java.lang.String password
protected BandwidthThrottler throttler
protected DataChannelCallback dataChannelCallback
protected boolean useNOOP
public FTPClient(java.lang.String remoteHost) throws java.io.IOException, FTPException
remoteHost
- the remote hostnamejava.io.IOException
FTPException
public FTPClient(java.lang.String remoteHost, int controlPort) throws java.io.IOException, FTPException
remoteHost
- the remote hostnamecontrolPort
- port for control stream (-1 for default port)java.io.IOException
FTPException
public FTPClient(java.lang.String remoteHost, int controlPort, int timeout) throws java.io.IOException, FTPException
remoteHost
- the remote hostnamecontrolPort
- port for control stream (use -1 for the default port)timeout
- the length of the timeout, in milliseconds
(pass in 0 for no timeout)java.io.IOException
FTPException
public FTPClient(java.lang.String remoteHost, int controlPort, int timeout, java.lang.String encoding) throws java.io.IOException, FTPException
remoteHost
- the remote hostnamecontrolPort
- port for control stream (use -1 for the default port)timeout
- the length of the timeout, in milliseconds
(pass in 0 for no timeout)encoding
- character encoding used for datajava.io.IOException
FTPException
public FTPClient(java.net.InetAddress remoteAddr) throws java.io.IOException, FTPException
remoteAddr
- the address of the
remote hostjava.io.IOException
FTPException
public FTPClient(java.net.InetAddress remoteAddr, int controlPort) throws java.io.IOException, FTPException
remoteAddr
- the address of the
remote hostcontrolPort
- port for control streamjava.io.IOException
FTPException
public FTPClient(java.net.InetAddress remoteAddr, int controlPort, int timeout) throws java.io.IOException, FTPException
remoteAddr
- the address of the
remote hostcontrolPort
- port for control stream (-1 for default port)timeout
- the length of the timeout, in milliseconds
(pass in 0 for no timeout)java.io.IOException
FTPException
public FTPClient(java.net.InetAddress remoteAddr, int controlPort, int timeout, java.lang.String encoding) throws java.io.IOException, FTPException
remoteAddr
- the address of the
remote hostcontrolPort
- port for control stream (-1 for default port)timeout
- the length of the timeout, in milliseconds
(pass in 0 for no timeout)encoding
- character encoding used for datajava.io.IOException
FTPException
public 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).public static int[] getVersion()
public static java.lang.String getBuildTimestamp()
public void connect() throws java.io.IOException, FTPException
connect
in interface FTPClientInterface
java.io.IOException
- Thrown if there is a TCP/IP-related error.FTPException
- Thrown if there is an error related to the FTP protocol.public boolean connected()
connected
in interface FTPClientInterface
protected void checkConnection(boolean shouldBeConnected) throws FTPException
FTPException
- Thrown if the client has not connected to the server.protected void initialize(FTPControlSocket control) throws java.io.IOException
control
- control socket referencejava.io.IOException
public void debugResponses(boolean on)
on
- true if you wish to have responses to
the log stream, false otherwisepublic java.lang.String getId()
getId
in interface FTPClientInterface
public void setId(java.lang.String id)
setId
in interface FTPClientInterface
id
- identifying stringpublic int getDownloadCount()
getDownloadCount
in interface FTPClientInterface
public void resetDownloadCount()
resetDownloadCount
in interface FTPClientInterface
public int getUploadCount()
getUploadCount
in interface FTPClientInterface
public void resetUploadCount()
resetUploadCount
in interface FTPClientInterface
public int getDeleteCount()
getDeleteCount
in interface FTPClientInterface
public void resetDeleteCount()
resetDeleteCount
in interface FTPClientInterface
public void setDataChannelCallback(DataChannelCallback callback)
callback
- callback to setpublic void setStrictReturnCodes(boolean strict)
strict
- true for strict checking, false for loose checkingpublic boolean isStrictReturnCodes()
public void setListenOnAllInterfaces(boolean listenOnAll)
listenOnAll
- true if listen on all interfaces, false to listen on the control interfacepublic boolean getListenOnAllInterfaces()
public FileNotFoundStrings getFileNotFoundMessages()
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.
public void setFileNotFoundMessages(FileNotFoundStrings fileNotFoundStrings)
fileNotFoundStrings
- new instancepublic TransferCompleteStrings getTransferCompleteMessages()
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.
public void setTransferCompleteMessages(TransferCompleteStrings transferCompleteStrings)
transferCompleteStrings
- new instancepublic DirectoryEmptyStrings getDirectoryEmptyMessages()
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.
public void setDirectoryEmptyMessages(DirectoryEmptyStrings dirEmptyStrings)
dirEmptyStrings
- new instancepublic void setDetectTransferMode(boolean detectTransferMode)
FTPClientInterface
setDetectTransferMode
in interface FTPClientInterface
detectTransferMode
- true if detecting transfer mode, false if notpublic boolean getDetectTransferMode()
FTPClientInterface
getDetectTransferMode
in interface FTPClientInterface
public void setFileLockingEnabled(boolean lockingEnabled)
FTPClientInterface
setFileLockingEnabled
in interface FTPClientInterface
lockingEnabled
- true to enable locking, false to disablepublic boolean getFileLockingEnabled()
FTPClientInterface
getFileLockingEnabled
in interface FTPClientInterface
public void setForceUniqueNames(boolean forceUnique)
forceUnique
- true if STOU is always to be usedprotected FTPTransferType chooseTransferMode(java.lang.String filename) throws java.io.IOException, FTPException
filename
- filename of file to be transferredFTPException
java.io.IOException
public void setTimeout(int millis) throws java.io.IOException
setTimeout
in interface FTPClientInterface
millis
- The length of the timeout, in millisecondsjava.io.IOException
public int getTimeout()
getTimeout
in interface FTPClientInterface
public int getRemotePort()
getControlPort()
.getRemotePort
in interface FTPClientInterface
public void setRemotePort(int remotePort) throws FTPException
setControlPort(int)
.setRemotePort
in interface FTPClientInterface
remotePort
- The port to use.FTPException
- Thrown if the client is already connected to the server.public int getControlPort()
FTPClientInterface.getRemotePort()
instead.public void setControlPort(int controlPort) throws FTPException
FTPClientInterface.setRemotePort(int)
instead.controlPort
- The port to use.FTPException
- Thrown if the client is already connected to the server.public java.net.InetAddress getRemoteAddr()
public void setRemoteAddr(java.net.InetAddress remoteAddr) throws FTPException
remoteAddr
- The remoteAddr to set.FTPException
public java.lang.String getRemoteHost()
FTPClientInterface
getRemoteHost
in interface FTPClientInterface
public void setRemoteHost(java.lang.String remoteHost) throws java.io.IOException, FTPException
FTPClientInterface
setRemoteHost
in interface FTPClientInterface
remoteHost
- The IP address or name of the remote hostFTPException
- Thrown if the client is already connected to the server.java.io.IOException
public boolean isAutoPassiveIPSubstitution()
public void setAutoPassiveIPSubstitution(boolean autoPassiveIPSubstitution)
autoPassiveIPSubstitution
- true if set to on, false otherwisepublic int getServerWakeupInterval()
public void setServerWakeupInterval(int interval)
interval
- interval in secondspublic java.lang.String getControlEncoding()
public int getNetworkBufferSize()
getNetworkBufferSize
in interface FTPClientInterface
public void setNetworkBufferSize(int networkBufferSize)
setNetworkBufferSize
in interface FTPClientInterface
networkBufferSize
- new buffer size to setpublic void setDataReceiveBufferSize(int size)
setNetworkBufferSize(int)
size
- must be > 0public int getDataReceiveBufferSize()
getNetworkBufferSize()
public void setDataSendBufferSize(int size)
setNetworkBufferSize(int)
size
- must be > 0public int getDataSendBufferSize()
getNetworkBufferSize()
public void setControlEncoding(java.lang.String controlEncoding) throws FTPException
setControlEncoding
in interface FTPClientInterface
controlEncoding
- The controlEncoding to set, which is the name of a CharsetFTPException
Charset
public FTPMessageListener getMessageListener()
public void setMessageListener(FTPMessageListener listener)
listener
- message listenerpublic FTPProgressMonitorEx getProgressMonitorEx()
public void setProgressMonitorEx(FTPProgressMonitorEx monitorEx)
monitorEx
- transfer listenerpublic void setConnectMode(FTPConnectMode mode)
mode
- ACTIVE or PASV modepublic FTPConnectMode getConnectMode()
public void setProgressMonitor(FTPProgressMonitor monitor, long interval)
FTPClientInterface
setProgressMonitor
in interface FTPClientInterface
monitor
- the monitor objectinterval
- bytes transferred in between callbackspublic void setProgressMonitor(FTPProgressMonitor monitor)
FTPClientInterface
setProgressMonitor
in interface FTPClientInterface
monitor
- the monitor objectpublic FTPProgressMonitor getProgressMonitor()
public long getMonitorInterval()
FTPClientInterface
getMonitorInterval
in interface FTPClientInterface
public void setMonitorInterval(long interval)
public void setTransferBufferSize(int size)
size
- new size of buffer in bytespublic int getTransferBufferSize()
public void cancelTransfer()
FTPClientInterface
cancelTransfer
in interface FTPClientInterface
public boolean isTransferCancelled()
public boolean isDeleteOnFailure()
public void setDeleteOnFailure(boolean deleteOnFailure)
deleteOnFailure
- true if delete when a failure occurspublic void setPORTIP(java.lang.String IPAddress) throws FTPException
IPAddress
- IP address to force, in 192.168.1.0 formFTPException
public void setActiveIPAddress(java.lang.String activeIP) throws FTPException
activeIP
- IP address to force, in 192.168.1.0 form or in IPV6 form, e.g.
1080::8:800:200C:417AFTPException
public java.lang.String getActiveIPAddress()
public void setActivePortRange(int lowest, int highest) throws FTPException
lowest
- Lower limit of range.highest
- Upper limit of range.FTPException
public int getActiveLowPort()
public int getActiveHighPort()
public void login(java.lang.String user, java.lang.String password) throws java.io.IOException, FTPException
user
- user namepassword
- user's passwordjava.io.IOException
FTPException
public void login(java.lang.String user, java.lang.String password, java.lang.String accountInfo) throws java.io.IOException, FTPException
user
- user namepassword
- user's passwordaccountInfo
- account info stringjava.io.IOException
FTPException
public void user(java.lang.String user) throws java.io.IOException, FTPException
user
- user namejava.io.IOException
FTPException
public void password(java.lang.String password) throws java.io.IOException, FTPException
password
- The password.java.io.IOException
FTPException
public void account(java.lang.String accountInfo) throws java.io.IOException, FTPException
accountInfo
- account information stringjava.io.IOException
FTPException
public static void initSOCKS(java.lang.String port, java.lang.String host)
port
- SOCKS proxy porthost
- SOCKS proxy hostnamepublic static void initSOCKSAuthentication(java.lang.String username, java.lang.String password)
username
- the SOCKS usernamepassword
- the SOCKS passwordpublic static void clearSOCKS()
public java.lang.String quote(java.lang.String command, java.lang.String[] validCodes) throws java.io.IOException, FTPException
command
- ftp command to be sent to servervalidCodes
- valid return codes for this command. If null
is supplied no validation is performedjava.io.IOException
FTPException
public java.lang.String quote(java.lang.String command) throws java.io.IOException, FTPException
command
- ftp command to be sent to serverjava.io.IOException
FTPException
public java.lang.String executeCommand(java.lang.String command) throws FTPException, java.io.IOException
executeCommand
in interface FTPClientInterface
command
- command stringFTPException
java.io.IOException
public boolean existsFile(java.lang.String remoteFile) throws java.io.IOException, FTPException
remoteFile
- File of which to check existence.java.io.IOException
- Thrown if there is a TCP/IP-related error.FTPException
- Thrown if there is an error related to the FTP protocol.public boolean existsDirectory(java.lang.String remoteDirectory) throws java.io.IOException, FTPException
remoteDirectory
- Directory of which to check existence.java.io.IOException
- Thrown if there is a TCP/IP-related error.FTPException
- Thrown if there is an error related to the FTP protocol.public boolean exists(java.lang.String remoteFile) throws java.io.IOException, FTPException
FTPClientInterface
exists
in interface FTPClientInterface
remoteFile
- name of remote filejava.io.IOException
FTPException
public FTPReply sendCommand(java.lang.String command) throws java.io.IOException, FTPException
command
- commandjava.io.IOException
FTPException
public void validateReply(FTPReply reply, java.lang.String expectedReplyCode) throws FTPException
reply
- reply objectexpectedReplyCode
- expected codeFTPException
public void validateReply(FTPReply reply, java.lang.String[] expectedReplyCodes) throws FTPException
reply
- reply objectexpectedReplyCodes
- expected codesFTPException
public long size(java.lang.String remoteFile) throws java.io.IOException, FTPException
FTPClientInterface
size
in interface FTPClientInterface
remoteFile
- name or path of remote file in current directoryjava.io.IOException
FTPException
public void resume() throws FTPException
FTPClientInterface
resume
in interface FTPClientInterface
FTPException
public void resumeNextDownload(long offset) throws FTPException
FTPClientInterface
resumeNextDownload
in interface FTPClientInterface
FTPException
public void cancelResume() throws java.io.IOException, FTPException
FTPClientInterface
cancelResume
in interface FTPClientInterface
java.io.IOException
FTPException
protected void forceResumeOff()
public void restart(long size) throws java.io.IOException, FTPException
size
- the REST param, the mark at which the restart is
performed on the remote file. For STOR, this is retrieved
by SIZEjava.io.IOException
FTPException
public int getRetryCount()
public void setRetryCount(int retryCount)
retryCount
- new retry countpublic int getRetryDelay()
public void setRetryDelay(int retryDelay)
new
- retry delay in millisecondspublic void get(java.lang.String localPath, java.lang.String remoteFile) throws java.io.IOException, FTPException
FTPClientInterface
get
in interface FTPClientInterface
localPath
- local file to put data inremoteFile
- name of remote file in
current directoryjava.io.IOException
FTPException
public java.lang.String put(java.io.InputStream srcStream, java.lang.String remoteFile, boolean append) throws java.io.IOException, FTPException
FTPClientInterface
put
in interface FTPClientInterface
srcStream
- input stream of data to putremoteFile
- name of remote file in
current directory, or null if
a unique filename is to be generated by the serverappend
- true if appending, false otherwisejava.io.IOException
FTPException
protected void reconnect(java.lang.String cwd) throws java.io.IOException, FTPException
cwd
- current working dirjava.io.IOException
FTPException
public java.lang.String put(java.lang.String localPath, java.lang.String remoteFile) throws java.io.IOException, FTPException
FTPClientInterface
put
in interface FTPClientInterface
localPath
- path of the local fileremoteFile
- name of remote file in
current directory, or null if
a unique filename is to be generated by the serverjava.io.IOException
FTPException
public java.lang.String put(java.io.InputStream srcStream, java.lang.String remoteFile) throws java.io.IOException, FTPException
FTPClientInterface
put
in interface FTPClientInterface
srcStream
- input stream of data to putremoteFile
- name of remote file in
current directory, or null if
a unique filename is to be generated by the serverjava.io.IOException
FTPException
public java.lang.String put(java.lang.String localPath, java.lang.String remoteFile, boolean append) throws java.io.IOException, FTPException
FTPClientInterface
put
in interface FTPClientInterface
localPath
- path of the local fileremoteFile
- name of remote file in current directory, or null if
a unique filename is to be generated by the serverappend
- true if appending, false otherwisejava.io.IOException
FTPException
public void validateTransfer() throws java.io.IOException, FTPException
java.io.IOException
FTPException
protected void validateTransferOnError(java.io.IOException ex) throws java.io.IOException, FTPException
java.io.IOException
FTPException
protected void closeDataSocket(java.io.InputStream stream)
stream
- stream referenceprotected void closeDataSocket(java.io.OutputStream stream)
stream
- stream referenceprotected void createDataSocket() throws java.io.IOException, FTPException
FTPException
java.io.IOException
protected void configureDataSocket() throws java.io.IOException
java.io.IOException
protected java.lang.String initPut(java.lang.String remoteFile, boolean append) throws java.io.IOException, FTPException
remoteFile
- name of remote file in current directoryappend
- true if appending, false otherwisejava.io.IOException
FTPException
public java.lang.String put(byte[] bytes, java.lang.String remoteFile) throws java.io.IOException, FTPException
FTPClientInterface
put
in interface FTPClientInterface
bytes
- array of bytesremoteFile
- name of remote file in
current directory, or null if
a unique filename is to be generated by the serverjava.io.IOException
FTPException
public java.lang.String put(byte[] bytes, java.lang.String remoteFile, boolean append) throws java.io.IOException, FTPException
FTPClientInterface
put
in interface FTPClientInterface
bytes
- array of bytesremoteFile
- name of remote file in
current directory, or null if
a unique filename is to be generated by the serverappend
- true if appending, false otherwisejava.io.IOException
FTPException
protected void postTransferChecks(java.lang.String localPath, java.lang.String remotePath, FTPTransferType transferType, boolean append) throws FTPException, java.io.IOException
localPath
- local fileremotePath
- remote filetransferType
- binary or ASCIIappend
- FTPException
java.io.IOException
protected void postTransferChecks(byte[] localBytes, java.lang.String remotePath, FTPTransferType transferType, boolean append) throws FTPException, java.io.IOException
localBytes
- local bytes to transferremotePath
- remote filetransferType
- binary or ASCIIappend
- FTPException
java.io.IOException
public void get(java.io.OutputStream destStream, java.lang.String remoteFile) throws java.io.IOException, FTPException
FTPClientInterface
get
in interface FTPClientInterface
destStream
- data stream to write data toremoteFile
- name of remote file in
current directoryjava.io.IOException
FTPException
public void resetTransferMode(FTPTransferType previousType) throws java.io.IOException, FTPException
previousType
- previous transfer typejava.io.IOException
FTPException
protected void initGet(java.lang.String remoteFile) throws java.io.IOException, FTPException
remoteFile
- name of remote filejava.io.IOException
FTPException
protected java.io.InputStream getInputStream() throws java.io.IOException
java.io.IOException
protected java.io.OutputStream getOutputStream() throws java.io.IOException
java.io.IOException
public byte[] get(java.lang.String remoteFile) throws java.io.IOException, FTPException
FTPClientInterface
get
in interface FTPClientInterface
remoteFile
- name of remote file in
current directoryjava.io.IOException
FTPException
public boolean site(java.lang.String command) throws java.io.IOException, FTPException
command
- the site command to runjava.io.IOException
FTPException
public java.lang.String list(java.lang.String dirname) throws java.io.IOException, FTPException
dir(String)
dirname
- the name of the directory (not a file mask)java.io.IOException
FTPException
public java.lang.String list(java.lang.String dirname, boolean full) throws java.io.IOException, FTPException
dir(String,boolean)
dirname
- the name of the directory(not a file mask)full
- true if detailed listing required
false otherwisejava.io.IOException
FTPException
public void setFTPFileFactory(FTPFileFactory fileFactory)
fileFactory
- public void setParserLocale(java.util.Locale locale)
locale
- new locale to usepublic void setParserLocales(java.util.Locale[] locales)
locales
- locales to usepublic FTPFile fileDetails(java.lang.String name) throws java.io.IOException, FTPException, java.text.ParseException
name
- name of a filejava.io.IOException
FTPException
java.text.ParseException
public FTPFile[] dirDetailsM(java.lang.String dirname) throws java.io.IOException, FTPException, java.text.ParseException
name
- name of a directoryjava.io.IOException
FTPException
java.text.ParseException
public void dirDetails(java.lang.String dirname, DirectoryListCallback lister) throws java.io.IOException, FTPException, java.text.ParseException
FTPClientInterface
dirDetails
in interface FTPClientInterface
dirname
- name of directory (some servers permit a filemask)lister
- callback to be notified of errorsjava.io.IOException
FTPException
java.text.ParseException
public FTPFile[] dirDetails(java.lang.String dirname) throws java.io.IOException, FTPException, java.text.ParseException
FTPClientInterface
dirDetails
in interface FTPClientInterface
dirname
- name of directory (some servers permit a filemask)java.io.IOException
FTPException
java.text.ParseException
public java.lang.String[] dir() throws java.io.IOException, FTPException
FTPClientInterface
dir
in interface FTPClientInterface
java.io.IOException
FTPException
public java.lang.String[] dir(java.lang.String dirname) throws java.io.IOException, FTPException
FTPClientInterface
dir
in interface FTPClientInterface
dirname
- name of directory OR filemaskjava.io.IOException
FTPException
public java.lang.String[] dir(java.lang.String dirname, boolean full) throws java.io.IOException, FTPException
FTPClientInterface
dir
in interface FTPClientInterface
dirname
- name of directory OR filemaskfull
- true if detailed listing required
false otherwisejava.io.IOException
FTPException
public int readChunk(java.io.BufferedInputStream in, byte[] chunk, int chunksize) throws java.io.IOException
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.in
- The InputStream
to read from.chunk
- The byte-array to place read bytes in.chunksize
- Number of bytes to read.java.io.IOException
- Thrown if there was an error while reading.public int readChunk(java.io.BufferedInputStream in, byte[] chunk, int offset, int chunksize) throws java.io.IOException
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.in
- The InputStream
to read from.chunk
- The byte-array to place read bytes in.offset
- Offset into chunkchunksize
- Number of bytes to read.java.io.IOException
- Thrown if there was an error while reading.protected int readChar(java.io.LineNumberReader in) throws java.io.IOException
InputStream
.
The purpose of this method is to permit subclasses to execute
any additional code necessary when performing this operation.in
- The LineNumberReader
to read from.java.io.IOException
- Thrown if there was an error while reading.protected java.lang.String readLine(java.io.LineNumberReader in) throws java.io.IOException
InputStream
.
The purpose of this method is to permit subclasses to execute
any additional code necessary when performing this operation.in
- The LineNumberReader
to read from.java.io.IOException
- Thrown if there was an error while reading.public FTPReply getLastValidReply()
public FTPReply getLastReply()
public FTPTransferType getType()
getType
in interface FTPClientInterface
public void setType(FTPTransferType type) throws java.io.IOException, FTPException
setType
in interface FTPClientInterface
type
- the transfer type to
set the server tojava.io.IOException
FTPException
public void delete(java.lang.String remoteFile) throws java.io.IOException, FTPException
FTPClientInterface
delete
in interface FTPClientInterface
remoteFile
- name of remote file to
deletejava.io.IOException
FTPException
public void rename(java.lang.String from, java.lang.String to) throws java.io.IOException, FTPException
FTPClientInterface
rename
in interface FTPClientInterface
from
- name of file or directory to renameto
- intended namejava.io.IOException
FTPException
public void rmdir(java.lang.String dir) throws java.io.IOException, FTPException
FTPClientInterface
rmdir
in interface FTPClientInterface
dir
- name of remote directory to
deletejava.io.IOException
FTPException
public void mkdir(java.lang.String dir) throws java.io.IOException, FTPException
FTPClientInterface
mkdir
in interface FTPClientInterface
dir
- name of remote directory to
createjava.io.IOException
FTPException
public void chdir(java.lang.String dir) throws java.io.IOException, FTPException
FTPClientInterface
chdir
in interface FTPClientInterface
dir
- name of remote directory to
change tojava.io.IOException
FTPException
public void cdup() throws java.io.IOException, FTPException
FTPClientInterface
cdup
in interface FTPClientInterface
java.io.IOException
FTPException
public java.util.Date modtime(java.lang.String remoteFile) throws java.io.IOException, FTPException
FTPClientInterface
modtime
in interface FTPClientInterface
remoteFile
- name of remote filejava.io.IOException
FTPException
public void setModTime(java.lang.String remoteFile, java.util.Date modTime) throws java.io.IOException, FTPException
FTPClientInterface
setModTime
in interface FTPClientInterface
remoteFile
- the path to the file/directory on the remote servermodTime
- the time stamp to set the modified time to in UTCjava.io.IOException
FTPException
public java.lang.String pwd() throws java.io.IOException, FTPException
FTPClientInterface
pwd
in interface FTPClientInterface
java.io.IOException
FTPException
public java.lang.String[] features() throws java.io.IOException, FTPException
java.io.IOException
FTPException
public java.lang.String system() throws java.io.IOException, FTPException
system
in interface FTPClientInterface
java.io.IOException
FTPException
public void noOperation() throws java.io.IOException, FTPException
java.io.IOException
FTPException
public void noOp() throws java.io.IOException, FTPException
java.io.IOException
FTPException
public java.lang.String stat() throws java.io.IOException, FTPException
java.io.IOException
FTPException
public void sendServerWakeup() throws java.io.IOException, FTPException
java.io.IOException
FTPException
public void keepAlive() throws java.io.IOException, FTPException
keepAlive
in interface FTPClientInterface
java.io.IOException
FTPException
public java.lang.String help(java.lang.String command) throws java.io.IOException, FTPException
command
- name of the command to get help onjava.io.IOException
FTPException
protected void abort() throws java.io.IOException, FTPException
java.io.IOException
FTPException
public void quit() throws java.io.IOException, FTPException
FTPClientInterface
quit
in interface FTPClientInterface
java.io.IOException
FTPException
public void quitImmediately() throws java.io.IOException, FTPException
FTPClientInterface
quitImmediately
in interface FTPClientInterface
java.io.IOException
FTPException
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2001-2014 Enterprise Distributed Technologies Ltd. All Rights Reserved.