public class FTP extends SocketClient
To derive the full benefits of the FTP class requires some knowledge
of the FTP protocol defined in RFC 959. However, there is no reason
why you should have to use the FTP class. The
FTPClient
class,
derived from FTP,
implements all the functionality required of an FTP client. The
FTP class is made public to provide access to various FTP constants
and to make it easier for adventurous programmers (or those with
special needs) to interact with the FTP protocol and implement their
own clients. A set of methods with names corresponding to the FTP
command names are provided to facilitate this interaction.
You should keep in mind that the FTP server may choose to prematurely
close a connection if the client has been idle for longer than a
given time period (usually 900 seconds). The FTP class will detect a
premature FTP server connection closing when it receives a
FTPReply.SERVICE_NOT_AVAILABLE
response to a command.
When that occurs, the FTP class method encountering that reply will throw
an FTPConnectionClosedException
. FTPConectionClosedException
is a subclass of IOException
and therefore need not be
caught separately, but if you are going to catch it separately, its
catch block must appear before the more general IOException
catch block. When you encounter an
FTPConnectionClosedException
, you must disconnect the connection with
disconnect()
to properly clean up the
system resources used by FTP. Before disconnecting, you may check the
last reply code and text with
getReplyCode
,
getReplyString
,
and getReplyStrings
.
You may avoid server disconnections while the client is idle by
periodicaly sending NOOP commands to the server.
Rather than list it separately for each method, we mention here that
every method communicating with the server and throwing an IOException
can also throw a
MalformedServerReplyException
, which is a subclass
of IOException. A MalformedServerReplyException will be thrown when
the reply received from the server deviates enough from the protocol
specification that it cannot be interpreted in a useful manner despite
attempts to be as lenient as possible.
FTPClient
,
FTPConnectionClosedException
,
MalformedServerReplyException
限定符和类型 | 字段和说明 |
---|---|
protected ProtocolCommandSupport |
_commandSupport_
A ProtocolCommandSupport object used to manage the registering of
ProtocolCommandListeners and te firing of ProtocolCommandEvents.
|
protected java.lang.String |
_controlEncoding |
protected java.io.BufferedReader |
_controlInput_
Wraps SocketClient.
|
protected java.io.BufferedWriter |
_controlOutput_
Wraps SocketClient.
|
protected boolean |
_newReplyString |
protected int |
_replyCode |
protected java.util.ArrayList<java.lang.String> |
_replyLines |
protected java.lang.String |
_replyString |
static int |
ASCII_FILE_TYPE
A constant used to indicate the file(s) being transferred should
be treated as ASCII.
|
static int |
BINARY_FILE_TYPE
A constant used to indicate the file(s) being transferred should
be treated as a binary image, i.e., no translations should be
performed.
|
static int |
BLOCK_TRANSFER_MODE
A constant used to indicate a file is to be transferred as a series
of blocks.
|
static int |
CARRIAGE_CONTROL_TEXT_FORMAT
A constant used to indicate a text file contains ASA vertical format
control characters.
|
static int |
COMPRESSED_TRANSFER_MODE
A constant used to indicate a file is to be transferred as FTP
compressed data.
|
static java.lang.String |
DEFAULT_CONTROL_ENCODING
The default character encoding used for communicating over an
FTP control connection.
|
static int |
DEFAULT_DATA_PORT
The default FTP data port (20).
|
static int |
DEFAULT_PORT
The default FTP control port (21).
|
static int |
EBCDIC_FILE_TYPE
A constant used to indicate the file(s) being transferred should
be treated as EBCDIC.
|
static int |
FILE_STRUCTURE
A constant used to indicate a file is to be treated as a continuous
sequence of bytes.
|
static int |
LOCAL_FILE_TYPE
A constant used to indicate the file(s) being transferred should
be treated as a local type.
|
static int |
NON_PRINT_TEXT_FORMAT
A constant used for text files to indicate a non-print text format.
|
static int |
PAGE_STRUCTURE
A constant used to indicate a file is to be treated as a set of
independent indexed pages.
|
static int |
RECORD_STRUCTURE
A constant used to indicate a file is to be treated as a sequence
of records.
|
static int |
REPLY_CODE_LEN
Length of the FTP reply code (3 alphanumerics)
|
static int |
STREAM_TRANSFER_MODE
A constant used to indicate a file is to be transferred as a stream
of bytes.
|
protected boolean |
strictMultilineParsing
This is used to signal whether a block of multiline responses beginning
with xxx must be terminated by the same numeric code xxx
See section 4.2 of RFC 959 for details.
|
static int |
TELNET_TEXT_FORMAT
A constant used to indicate a text file contains format vertical format
control characters.
|
_defaultPort_, _hostname_, _input_, _output_, _serverSocketFactory_, _socket_, _socketFactory_, _timeout_, connectTimeout, NETASCII_EOL
构造器和说明 |
---|
FTP()
The default FTP constructor.
|
限定符和类型 | 方法和说明 |
---|---|
protected void |
__getReplyNoReport()
Get the reply, but don't pass it to command listeners.
|
protected void |
__noop()
Send a noop and get the reply without reporting to the command listener.
|
protected void |
_connectAction_()
Initiates control connections and gets initial reply.
|
protected void |
_connectAction_(java.io.Reader socketIsReader)
Initiates control connections and gets initial reply.
|
int |
abor()
A convenience method to send the FTP ABOR command to the server,
receive the reply, and return the reply code.
|
int |
acct(java.lang.String account)
A convenience method to send the FTP ACCT command to the server,
receive the reply, and return the reply code.
|
int |
allo(int bytes)
A convenience method to send the FTP ALLO command to the server,
receive the reply, and return the reply code.
|
int |
allo(int bytes,
int recordSize)
A convenience method to send the FTP ALLO command to the server,
receive the reply, and return the reply code.
|
int |
appe(java.lang.String pathname)
A convenience method to send the FTP APPE command to the server,
receive the reply, and return the reply code.
|
int |
cdup()
A convenience method to send the FTP CDUP command to the server,
receive the reply, and return the reply code.
|
int |
cwd(java.lang.String directory)
A convenience method to send the FTP CWD command to the server,
receive the reply, and return the reply code.
|
int |
dele(java.lang.String pathname)
A convenience method to send the FTP DELE command to the server,
receive the reply, and return the reply code.
|
void |
disconnect()
Closes the control connection to the FTP server and sets to null
some internal data so that the memory may be reclaimed by the
garbage collector.
|
int |
eprt(java.net.InetAddress host,
int port)
A convenience method to send the FTP EPRT command to the server,
receive the reply, and return the reply code.
|
int |
epsv()
A convenience method to send the FTP EPSV command to the server,
receive the reply, and return the reply code.
|
int |
feat()
A convenience method to send the FTP FEAT command to the server, receive the reply,
and return the reply code.
|
protected ProtocolCommandSupport |
getCommandSupport()
Provide command support to super-class
|
java.lang.String |
getControlEncoding() |
int |
getReply()
Fetches a reply from the FTP server and returns the integer reply
code.
|
int |
getReplyCode()
Returns the integer value of the reply code of the last FTP reply.
|
java.lang.String |
getReplyString()
Returns the entire text of the last FTP server response exactly
as it was received, including all end of line markers in NETASCII
format.
|
java.lang.String[] |
getReplyStrings()
Returns the lines of text from the last FTP server response as an array
of strings, one entry per line.
|
int |
help()
A convenience method to send the FTP HELP command to the server,
receive the reply, and return the reply code.
|
int |
help(java.lang.String command)
A convenience method to send the FTP HELP command to the server,
receive the reply, and return the reply code.
|
boolean |
isStrictMultilineParsing()
Return whether strict multiline parsing is enabled, as per RFC 959, section 4.2.
|
boolean |
isStrictReplyParsing()
Return whether strict non-multiline parsing is enabled, as per RFC 959, section 4.2.
|
int |
list()
A convenience method to send the FTP LIST command to the server,
receive the reply, and return the reply code.
|
int |
list(java.lang.String pathname)
A convenience method to send the FTP LIST command to the server,
receive the reply, and return the reply code.
|
int |
mdtm(java.lang.String file) |
int |
mfmt(java.lang.String pathname,
java.lang.String timeval)
A convenience method to send the FTP MFMT command to the server,
receive the reply, and return the reply code.
|
int |
mkd(java.lang.String pathname)
A convenience method to send the FTP MKD command to the server,
receive the reply, and return the reply code.
|
int |
mlsd()
A convenience method to send the FTP MLSD command to the server,
receive the reply, and return the reply code.
|
int |
mlsd(java.lang.String path)
A convenience method to send the FTP MLSD command to the server,
receive the reply, and return the reply code.
|
int |
mlst()
A convenience method to send the FTP MLST command to the server,
receive the reply, and return the reply code.
|
int |
mlst(java.lang.String path)
A convenience method to send the FTP MLST command to the server,
receive the reply, and return the reply code.
|
int |
mode(int mode)
A convenience method to send the FTP MODE command to the server,
receive the reply, and return the reply code.
|
int |
nlst()
A convenience method to send the FTP NLST command to the server,
receive the reply, and return the reply code.
|
int |
nlst(java.lang.String pathname)
A convenience method to send the FTP NLST command to the server,
receive the reply, and return the reply code.
|
int |
noop()
A convenience method to send the FTP NOOP command to the server,
receive the reply, and return the reply code.
|
int |
pass(java.lang.String password)
A convenience method to send the FTP PASS command to the server,
receive the reply, and return the reply code.
|
int |
pasv()
A convenience method to send the FTP PASV command to the server,
receive the reply, and return the reply code.
|
int |
port(java.net.InetAddress host,
int port)
A convenience method to send the FTP PORT command to the server,
receive the reply, and return the reply code.
|
int |
pwd()
A convenience method to send the FTP PWD command to the server,
receive the reply, and return the reply code.
|
int |
quit()
A convenience method to send the FTP QUIT command to the server,
receive the reply, and return the reply code.
|
int |
rein()
A convenience method to send the FTP REIN command to the server,
receive the reply, and return the reply code.
|
int |
rest(java.lang.String marker)
A convenience method to send the FTP REST command to the server,
receive the reply, and return the reply code.
|
int |
retr(java.lang.String pathname)
A convenience method to send the FTP RETR command to the server,
receive the reply, and return the reply code.
|
int |
rmd(java.lang.String pathname)
A convenience method to send the FTP RMD command to the server,
receive the reply, and return the reply code.
|
int |
rnfr(java.lang.String pathname)
A convenience method to send the FTP RNFR command to the server,
receive the reply, and return the reply code.
|
int |
rnto(java.lang.String pathname)
A convenience method to send the FTP RNTO command to the server,
receive the reply, and return the reply code.
|
int |
sendCommand(FTPCmd command)
Sends an FTP command to the server, waits for a reply and returns the
numerical response code.
|
int |
sendCommand(FTPCmd command,
java.lang.String args)
Sends an FTP command to the server, waits for a reply and returns the
numerical response code.
|
int |
sendCommand(java.lang.String command)
Sends an FTP command with no arguments to the server, waits for a
reply and returns the numerical response code.
|
int |
sendCommand(java.lang.String command,
java.lang.String args)
Sends an FTP command to the server, waits for a reply and returns the
numerical response code.
|
void |
setControlEncoding(java.lang.String encoding)
Saves the character encoding to be used by the FTP control connection.
|
void |
setStrictMultilineParsing(boolean strictMultilineParsing)
Set strict multiline parsing.
|
void |
setStrictReplyParsing(boolean strictReplyParsing)
Set strict non-multiline parsing.
|
int |
site(java.lang.String parameters)
A convenience method to send the FTP SITE command to the server,
receive the reply, and return the reply code.
|
int |
smnt(java.lang.String dir)
A convenience method to send the FTP SMNT command to the server,
receive the reply, and return the reply code.
|
int |
stat()
A convenience method to send the FTP STAT command to the server,
receive the reply, and return the reply code.
|
int |
stat(java.lang.String pathname)
A convenience method to send the FTP STAT command to the server,
receive the reply, and return the reply code.
|
int |
stor(java.lang.String pathname)
A convenience method to send the FTP STOR command to the server,
receive the reply, and return the reply code.
|
int |
stou()
A convenience method to send the FTP STOU command to the server,
receive the reply, and return the reply code.
|
int |
stou(java.lang.String pathname)
A convenience method to send the FTP STOU command to the server,
receive the reply, and return the reply code.
|
int |
stru(int structure)
A convenience method to send the FTP STRU command to the server,
receive the reply, and return the reply code.
|
int |
syst()
A convenience method to send the FTP SYST command to the server,
receive the reply, and return the reply code.
|
int |
type(int fileType)
A convenience method to send the FTP TYPE command to the server,
receive the reply, and return the reply code.
|
int |
type(int fileType,
int formatOrByteSize)
A convenience method to send the FTP TYPE command for text files
to the server, receive the reply, and return the reply code.
|
int |
user(java.lang.String username)
A convenience method to send the FTP USER command to the server,
receive the reply, and return the reply code.
|
addProtocolCommandListener, connect, connect, connect, connect, connect, connect, createCommandSupport, fireCommandSent, fireReplyReceived, getCharset, getConnectTimeout, getDefaultPort, getDefaultTimeout, getKeepAlive, getLocalAddress, getLocalPort, getProxy, getReceiveBufferSize, getRemoteAddress, getRemotePort, getSendBufferSize, getServerSocketFactory, getSoLinger, getSoTimeout, getTcpNoDelay, isAvailable, isConnected, removeProtocolCommandListener, setCharset, setConnectTimeout, setDefaultPort, setDefaultTimeout, setKeepAlive, setProxy, setReceiveBufferSize, setSendBufferSize, setServerSocketFactory, setSocketFactory, setSoLinger, setSoTimeout, setTcpNoDelay, verifyRemote
public static final int DEFAULT_DATA_PORT
public static final int DEFAULT_PORT
public static final int ASCII_FILE_TYPE
FILE_TYPE
are used to indicate file types.public static final int EBCDIC_FILE_TYPE
FILE_TYPE
are used to indicate file types.public static final int BINARY_FILE_TYPE
FILE_TYPE
are used to
indicate file types.public static final int LOCAL_FILE_TYPE
FILE_TYPE
are used to indicate file types.public static final int NON_PRINT_TEXT_FORMAT
TEXT_FORMAT
are used to indicate
text formatting for text transfers (both ASCII and EBCDIC).public static final int TELNET_TEXT_FORMAT
TEXT_FORMAT
are used to indicate
text formatting for text transfers (both ASCII and EBCDIC).public static final int CARRIAGE_CONTROL_TEXT_FORMAT
TEXT_FORMAT
are used to indicate
text formatting for text transfers (both ASCII and EBCDIC).public static final int FILE_STRUCTURE
_STRUCTURE
are used to indicate file structure for
file transfers.public static final int RECORD_STRUCTURE
_STRUCTURE
are used to indicate file structure for file transfers.public static final int PAGE_STRUCTURE
_STRUCTURE
are used to indicate file structure for file
transfers.public static final int STREAM_TRANSFER_MODE
TRANSFER_MODE
are used to indicate file transfer
modes.public static final int BLOCK_TRANSFER_MODE
TRANSFER_MODE
are used
to indicate file transfer modes.public static final int COMPRESSED_TRANSFER_MODE
TRANSFER_MODE
are used to indicate file transfer modes.public static final java.lang.String DEFAULT_CONTROL_ENCODING
setControlEncoding
.public static final int REPLY_CODE_LEN
protected int _replyCode
protected java.util.ArrayList<java.lang.String> _replyLines
protected boolean _newReplyString
protected java.lang.String _replyString
protected java.lang.String _controlEncoding
protected ProtocolCommandSupport _commandSupport_
protected boolean strictMultilineParsing
protected java.io.BufferedReader _controlInput_
_connectAction_()
,
and set to null in disconnect()
.protected java.io.BufferedWriter _controlOutput_
_connectAction_()
,
and set to null in disconnect()
.public FTP()
DEFAULT_PORT
and initializes internal data structures
for saving FTP reply information.protected void __getReplyNoReport() throws java.io.IOException
java.io.IOException
- on errorprotected void _connectAction_() throws java.io.IOException
_controlInput_
and _controlOutput_
._connectAction_
在类中 SocketClient
java.io.IOException
- (SocketException) if a problem occurs with the socketprotected void _connectAction_(java.io.Reader socketIsReader) throws java.io.IOException
_controlInput_
and _controlOutput_
.socketIsReader
- the reader to reuse (if non-null)java.io.IOException
- on errorpublic void setControlEncoding(java.lang.String encoding)
Please note that this has to be set before the connection is established.
encoding
- The new character encoding for the control connection.public java.lang.String getControlEncoding()
public void disconnect() throws java.io.IOException
_controlInput_
and _controlOutput_
to null.disconnect
在类中 SocketClient
java.io.IOException
- If an error occurs while disconnecting.public int sendCommand(java.lang.String command, java.lang.String args) throws java.io.IOException
getReplyString
or
getReplyStrings
.command
- The text representation of the FTP command to send.args
- The arguments to the FTP command. If this parameter is
set to null, then the command is sent with no argument.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.protected void __noop() throws java.io.IOException
java.io.IOException
- on errorpublic int sendCommand(FTPCmd command) throws java.io.IOException
getReplyString
or
getReplyStrings
.command
- The FTPCmd enum corresponding to the FTP command
to send.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int sendCommand(FTPCmd command, java.lang.String args) throws java.io.IOException
getReplyString
or
getReplyStrings
.command
- The FTPCmd enum corresponding to the FTP command
to send.args
- The arguments to the FTP command. If this parameter is
set to null, then the command is sent with no argument.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int sendCommand(java.lang.String command) throws java.io.IOException
getReplyString
or
getReplyStrings
.command
- The text representation of the FTP command to send.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int getReplyCode()
connect
is of type void.public int getReply() throws java.io.IOException
getReplyString
or
getReplyStrings
. Only use this
method if you are implementing your own FTP client or if you need to
fetch a secondary response from the FTP server.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while receiving the
server reply.public java.lang.String[] getReplyStrings()
public java.lang.String getReplyString()
public int user(java.lang.String username) throws java.io.IOException
username
- The username to login under.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int pass(java.lang.String password) throws java.io.IOException
password
- The plain text password of the username being logged into.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int acct(java.lang.String account) throws java.io.IOException
account
- The account name to access.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int abor() throws java.io.IOException
FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int cwd(java.lang.String directory) throws java.io.IOException
directory
- The new working directory.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int cdup() throws java.io.IOException
FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int quit() throws java.io.IOException
FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int rein() throws java.io.IOException
FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int smnt(java.lang.String dir) throws java.io.IOException
dir
- The directory name.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int port(java.net.InetAddress host, int port) throws java.io.IOException
host
- The host owning the port.port
- The new port.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int eprt(java.net.InetAddress host, int port) throws java.io.IOException
host
- The host owning the port.port
- The new port.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int pasv() throws java.io.IOException
FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int epsv() throws java.io.IOException
FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int type(int fileType, int formatOrByteSize) throws java.io.IOException
fileType
- The type of the file (one of the FILE_TYPE
constants).formatOrByteSize
- The format of the file (one of the
_FORMAT
constants. In the case of
LOCAL_FILE_TYPE
, the byte size.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int type(int fileType) throws java.io.IOException
fileType
- The type of the file (one of the FILE_TYPE
constants).FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int stru(int structure) throws java.io.IOException
structure
- The structure of the file (one of the
_STRUCTURE
constants).FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int mode(int mode) throws java.io.IOException
mode
- The transfer mode to use (one of the
TRANSFER_MODE
constants).FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int retr(java.lang.String pathname) throws java.io.IOException
FTPClient
, which will handle all low level details for you.pathname
- The pathname of the file to retrieve.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int stor(java.lang.String pathname) throws java.io.IOException
FTPClient
, which will handle all low level details for you.pathname
- The pathname to use for the file when stored at
the remote end of the transfer.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int stou() throws java.io.IOException
FTPClient
, which will handle all low level details for you.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int stou(java.lang.String pathname) throws java.io.IOException
FTPClient
, which will handle all low level details for you.pathname
- The base pathname to use for the file when stored at
the remote end of the transfer. Some FTP servers
require this.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int appe(java.lang.String pathname) throws java.io.IOException
FTPClient
, which will handle all low level details for you.pathname
- The pathname to use for the file when stored at
the remote end of the transfer.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int allo(int bytes) throws java.io.IOException
bytes
- The number of bytes to allocate.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int feat() throws java.io.IOException
java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int allo(int bytes, int recordSize) throws java.io.IOException
bytes
- The number of bytes to allocate.recordSize
- The size of a record.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int rest(java.lang.String marker) throws java.io.IOException
marker
- The marker at which to restart a transfer.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int mdtm(java.lang.String file) throws java.io.IOException
file
- name of filejava.io.IOException
- on errorpublic int mfmt(java.lang.String pathname, java.lang.String timeval) throws java.io.IOException
pathname
- The pathname for which mtime is to be changedtimeval
- Timestamp in YYYYMMDDhhmmss
formatFTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int rnfr(java.lang.String pathname) throws java.io.IOException
pathname
- The pathname to rename from.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int rnto(java.lang.String pathname) throws java.io.IOException
pathname
- The pathname to rename toFTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int dele(java.lang.String pathname) throws java.io.IOException
pathname
- The pathname to delete.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int rmd(java.lang.String pathname) throws java.io.IOException
pathname
- The pathname of the directory to remove.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int mkd(java.lang.String pathname) throws java.io.IOException
pathname
- The pathname of the new directory to create.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int pwd() throws java.io.IOException
FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int list() throws java.io.IOException
FTPClient
, which will handle all low level details for you.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int list(java.lang.String pathname) throws java.io.IOException
FTPClient
, which will handle all low level details for you.pathname
- The pathname to list,
may be null
in which case the command is sent with no parametersFTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int mlsd() throws java.io.IOException
FTPClient
, which will handle all low level details for you.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int mlsd(java.lang.String path) throws java.io.IOException
FTPClient
, which will handle all low level details for you.path
- the path to report onnull
in which case the command is sent with no parametersFTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int mlst() throws java.io.IOException
FTPClient
, which will handle all low level details for you.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int mlst(java.lang.String path) throws java.io.IOException
FTPClient
, which will handle all low level details for you.path
- the path to report onnull
in which case the command is sent with no parametersFTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int nlst() throws java.io.IOException
FTPClient
, which will handle all low level details for you.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int nlst(java.lang.String pathname) throws java.io.IOException
FTPClient
, which will handle all low level details for you.pathname
- The pathname to list,
may be null
in which case the command is sent with no parametersFTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int site(java.lang.String parameters) throws java.io.IOException
parameters
- The site parameters to send.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int syst() throws java.io.IOException
FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int stat() throws java.io.IOException
FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int stat(java.lang.String pathname) throws java.io.IOException
pathname
- A pathname to list.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int help() throws java.io.IOException
FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int help(java.lang.String command) throws java.io.IOException
command
- The command name on which to request help.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public int noop() throws java.io.IOException
FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a result
of the client being idle or some other reason causing the server
to send FTP reply code 421. This exception may be caught either
as an IOException or independently as itself.java.io.IOException
- If an I/O error occurs while either sending the
command or receiving the server reply.public boolean isStrictMultilineParsing()
public void setStrictMultilineParsing(boolean strictMultilineParsing)
strictMultilineParsing
- the settingpublic boolean isStrictReplyParsing()
The default is true, which requires the 3 digit code be followed by space and some text.
If false, only the 3 digit code is required (as was the case for versions up to 3.5)
public void setStrictReplyParsing(boolean strictReplyParsing)
If true, it requires the 3 digit code be followed by space and some text.
If false, only the 3 digit code is required (as was the case for versions up to 3.5)
This should not be required by a well-behaved FTP server
strictReplyParsing
- the settingprotected ProtocolCommandSupport getCommandSupport()
getCommandSupport
在类中 SocketClient
null