Class FTP
- java.lang.Object
-
- com.oroinc.net.SocketClient
-
- com.oroinc.net.telnet.TelnetClient
-
- com.oroinc.net.ftp.FTP
-
- Direct Known Subclasses:
FTPClient
public class FTP extends TelnetClient
FTP provides the basic the functionality necessary to implement your own FTP client. It extends com.oroinc.net.TelnetClient simply because it saves the writing of extra code to handle the FTP control connection which always remains open during an FTP session and uses the Telnet protocol. Aggregation would require writing new wrapper methods and wouldn't leverage the functionality already present in com.oroinc.net.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 .
FTPConectionClosedExceptionis a subclass ofIOExceptionand therefore need not be caught separately, but if you are going to catch it separately, its catch block must appear before the more generalIOExceptioncatch 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.
- Author:
- Daniel F. Savarese
- See Also:
FTPClient,FTPConnectionClosedException,MalformedServerReplyException
-
-
Field Summary
Fields Modifier and Type Field Description protected ProtocolCommandSupport_commandSupport_A ProtocolCommandSupport object used to manage the registering of ProtocolCommandListeners and te firing of ProtocolCommandEvents.static intASCII_FILE_TYPEA constant used to indicate the file(s) being transfered should be treated as ASCII.static intBINARY_FILE_TYPEA constant used to indicate the file(s) being transfered should be treated as a binary image, i.e., no translations should be performed.static intBLOCK_TRANSFER_MODEA constant used to indicate a file is to be transfered as a series of blocks.static intCARRIAGE_CONTROL_TEXT_FORMATA constant used to indicate a text file contains ASA vertical format control characters.static intCOMPRESSED_TRANSFER_MODEA constant used to indicate a file is to be transfered as FTP compressed data.static intDEFAULT_DATA_PORTThe default FTP data port (20).static intDEFAULT_PORTThe default FTP control port (21).static intEBCDIC_FILE_TYPEA constant used to indicate the file(s) being transfered should be treated as EBCDIC.static intFILE_STRUCTUREA constant used to indicate a file is to be treated as a continuous sequence of bytes.static intIMAGE_FILE_TYPEA constant used to indicate the file(s) being transfered should be treated as a binary image, i.e., no translations should be performed.static intLOCAL_FILE_TYPEA constant used to indicate the file(s) being transfered should be treated as a local type.static intNON_PRINT_TEXT_FORMATA constant used for text files to indicate a non-print text format.static intPAGE_STRUCTUREA constant used to indicate a file is to be treated as a set of independent indexed pages.static intRECORD_STRUCTUREA constant used to indicate a file is to be treated as a sequence of records.static intSTREAM_TRANSFER_MODEA constant used to indicate a file is to be transfered as a stream of bytes.static intTELNET_TEXT_FORMATA constant used to indicate a text file contains format vertical format control characters.-
Fields inherited from class com.oroinc.net.SocketClient
_defaultPort_, _input_, _isConnected_, _output_, _socket_, _socketFactory_, _timeout_, NETASCII_EOL
-
-
Constructor Summary
Constructors Constructor Description FTP()The default FTP constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void_connectAction_()Handles special connection requirements.intabor()A convenience method to send the FTP ABOR command to the server, receive the reply, and return the reply code.intacct(java.lang.String account)A convenience method to send the FTP ACCT command to the server, receive the reply, and return the reply code.voidaddProtocolCommandListener(ProtocolCommandListener listener)Adds a ProtocolCommandListener.intallo(int bytes)A convenience method to send the FTP ALLO command to the server, receive the reply, and return the reply code.intallo(int bytes, int recordSize)A convenience method to send the FTP ALLO command to the server, receive the reply, and return the reply code.intappe(java.lang.String pathname)A convenience method to send the FTP APPE command to the server, receive the reply, and return the reply code.intcdup()A convenience method to send the FTP CDUP command to the server, receive the reply, and return the reply code.intcwd(java.lang.String directory)A convenience method to send the FTP CWD command to the server, receive the reply, and return the reply code.intdele(java.lang.String pathname)A convenience method to send the FTP DELE command to the server, receive the reply, and return the reply code.voiddisconnect()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.intgetReply()Fetches a reply from the FTP server and returns the integer reply code.intgetReplyCode()Returns the integer value of the reply code of the last FTP reply.java.lang.StringgetReplyString()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.inthelp()A convenience method to send the FTP HELP command to the server, receive the reply, and return the reply code.inthelp(java.lang.String command)A convenience method to send the FTP HELP command to the server, receive the reply, and return the reply code.intlist()A convenience method to send the FTP LIST command to the server, receive the reply, and return the reply code.intlist(java.lang.String pathname)A convenience method to send the FTP LIST command to the server, receive the reply, and return the reply code.intmkd(java.lang.String pathname)A convenience method to send the FTP MKD command to the server, receive the reply, and return the reply code.intmode(int mode)A convenience method to send the FTP MODE command to the server, receive the reply, and return the reply code.intnlst()A convenience method to send the FTP NLST command to the server, receive the reply, and return the reply code.intnlst(java.lang.String pathname)A convenience method to send the FTP NLST command to the server, receive the reply, and return the reply code.intnoop()A convenience method to send the FTP NOOP command to the server, receive the reply, and return the reply code.intpass(java.lang.String password)A convenience method to send the FTP PASS command to the server, receive the reply, and return the reply code.intpasv()A convenience method to send the FTP PASV command to the server, receive the reply, and return the reply code.intport(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.intpwd()A convenience method to send the FTP PWD command to the server, receive the reply, and return the reply code.intquit()A convenience method to send the FTP QUIT command to the server, receive the reply, and return the reply code.intrein()A convenience method to send the FTP REIN command to the server, receive the reply, and return the reply code.voidremoveProtocolCommandistener(ProtocolCommandListener listener)Removes a ProtocolCommandListener.intrest(java.lang.String marker)A convenience method to send the FTP REST command to the server, receive the reply, and return the reply code.intretr(java.lang.String pathname)A convenience method to send the FTP RETR command to the server, receive the reply, and return the reply code.intrmd(java.lang.String pathname)A convenience method to send the FTP RMD command to the server, receive the reply, and return the reply code.intrnfr(java.lang.String pathname)A convenience method to send the FTP RNFR command to the server, receive the reply, and return the reply code.intrnto(java.lang.String pathname)A convenience method to send the FTP RNTO command to the server, receive the reply, and return the reply code.intsendCommand(int command)Sends an FTP command with no arguments to the server, waits for a reply and returns the numerical response code.intsendCommand(int command, java.lang.String args)Sends an FTP command to the server, waits for a reply and returns the numerical response code.intsendCommand(java.lang.String command)Sends an FTP command with no arguments to the server, waits for a reply and returns the numerical response code.intsendCommand(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.intsite(java.lang.String parameters)A convenience method to send the FTP SITE command to the server, receive the reply, and return the reply code.intsmnt(java.lang.String dir)A convenience method to send the FTP SMNT command to the server, receive the reply, and return the reply code.intstat()A convenience method to send the FTP STAT command to the server, receive the reply, and return the reply code.intstat(java.lang.String pathname)A convenience method to send the FTP STAT command to the server, receive the reply, and return the reply code.intstor(java.lang.String pathname)A convenience method to send the FTP STOR command to the server, receive the reply, and return the reply code.intstou()A convenience method to send the FTP STOU command to the server, receive the reply, and return the reply code.intstou(java.lang.String filename)A convenience method to send the FTP STOU command to the server, receive the reply, and return the reply code.intstru(int structure)A convenience method to send the FTP STRU command to the server, receive the reply, and return the reply code.intsyst()A convenience method to send the FTP SYST command to the server, receive the reply, and return the reply code.inttype(int fileType)A convenience method to send the FTP TYPE command to the server, receive the reply, and return the reply code.inttype(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.intuser(java.lang.String username)A convenience method to send the FTP USER command to the server, receive the reply, and return the reply code.-
Methods inherited from class com.oroinc.net.telnet.TelnetClient
getInputStream, getOutputStream
-
Methods inherited from class com.oroinc.net.SocketClient
connect, connect, connect, connect, connect, connect, getDefaultPort, getDefaultTimeout, getLocalAddress, getLocalPort, getRemoteAddress, getRemotePort, getSoLinger, getSoTimeout, getTcpNoDelay, isConnected, setDefaultPort, setDefaultTimeout, setSocketFactory, setSoLinger, setSoTimeout, setTcpNoDelay, verifyRemote
-
-
-
-
Field Detail
-
DEFAULT_DATA_PORT
public static final int DEFAULT_DATA_PORT
The default FTP data port (20).- See Also:
- Constant Field Values
-
DEFAULT_PORT
public static final int DEFAULT_PORT
The default FTP control port (21).- See Also:
- Constant Field Values
-
ASCII_FILE_TYPE
public static final int ASCII_FILE_TYPE
A constant used to indicate the file(s) being transfered should be treated as ASCII. This is the default file type. All constants ending inFILE_TYPEare used to indicate file types.- See Also:
- Constant Field Values
-
EBCDIC_FILE_TYPE
public static final int EBCDIC_FILE_TYPE
A constant used to indicate the file(s) being transfered should be treated as EBCDIC. Note however that there are several different EBCDIC formats. All constants ending inFILE_TYPEare used to indicate file types.- See Also:
- Constant Field Values
-
IMAGE_FILE_TYPE
public static final int IMAGE_FILE_TYPE
A constant used to indicate the file(s) being transfered should be treated as a binary image, i.e., no translations should be performed. All constants ending inFILE_TYPEare used to indicate file types.- See Also:
- Constant Field Values
-
BINARY_FILE_TYPE
public static final int BINARY_FILE_TYPE
A constant used to indicate the file(s) being transfered should be treated as a binary image, i.e., no translations should be performed. All constants ending inFILE_TYPEare used to indicate file types.- See Also:
- Constant Field Values
-
LOCAL_FILE_TYPE
public static final int LOCAL_FILE_TYPE
A constant used to indicate the file(s) being transfered should be treated as a local type. All constants ending inFILE_TYPEare used to indicate file types.- See Also:
- Constant Field Values
-
NON_PRINT_TEXT_FORMAT
public static final int NON_PRINT_TEXT_FORMAT
A constant used for text files to indicate a non-print text format. This is the default format. All constants ending inTEXT_FORMATare used to indicate text formatting for text transfers (both ASCII and EBCDIC).- See Also:
- Constant Field Values
-
TELNET_TEXT_FORMAT
public static final int TELNET_TEXT_FORMAT
A constant used to indicate a text file contains format vertical format control characters. All constants ending inTEXT_FORMATare used to indicate text formatting for text transfers (both ASCII and EBCDIC).- See Also:
- Constant Field Values
-
CARRIAGE_CONTROL_TEXT_FORMAT
public static final int CARRIAGE_CONTROL_TEXT_FORMAT
A constant used to indicate a text file contains ASA vertical format control characters. All constants ending inTEXT_FORMATare used to indicate text formatting for text transfers (both ASCII and EBCDIC).- See Also:
- Constant Field Values
-
FILE_STRUCTURE
public static final int FILE_STRUCTURE
A constant used to indicate a file is to be treated as a continuous sequence of bytes. This is the default structure. All constants ending in_STRUCTUREare used to indicate file structure for file transfers.- See Also:
- Constant Field Values
-
RECORD_STRUCTURE
public static final int RECORD_STRUCTURE
A constant used to indicate a file is to be treated as a sequence of records. All constants ending in_STRUCTUREare used to indicate file structure for file transfers.- See Also:
- Constant Field Values
-
PAGE_STRUCTURE
public static final int PAGE_STRUCTURE
A constant used to indicate a file is to be treated as a set of independent indexed pages. All constants ending in_STRUCTUREare used to indicate file structure for file transfers.- See Also:
- Constant Field Values
-
STREAM_TRANSFER_MODE
public static final int STREAM_TRANSFER_MODE
A constant used to indicate a file is to be transfered as a stream of bytes. This is the default transfer mode. All constants ending inTRANSFER_MODEare used to indicate file transfer modes.- See Also:
- Constant Field Values
-
BLOCK_TRANSFER_MODE
public static final int BLOCK_TRANSFER_MODE
A constant used to indicate a file is to be transfered as a series of blocks. All constants ending inTRANSFER_MODEare used to indicate file transfer modes.- See Also:
- Constant Field Values
-
COMPRESSED_TRANSFER_MODE
public static final int COMPRESSED_TRANSFER_MODE
A constant used to indicate a file is to be transfered as FTP compressed data. All constants ending inTRANSFER_MODEare used to indicate file transfer modes.- See Also:
- Constant Field Values
-
_commandSupport_
protected ProtocolCommandSupport _commandSupport_
A ProtocolCommandSupport object used to manage the registering of ProtocolCommandListeners and te firing of ProtocolCommandEvents.
-
-
Method Detail
-
_connectAction_
protected void _connectAction_() throws java.io.IOExceptionDescription copied from class:TelnetClientHandles special connection requirements.- Overrides:
_connectAction_in classTelnetClient- Throws:
java.io.IOException- If an error occurs during connection setup.
-
addProtocolCommandListener
public void addProtocolCommandListener(ProtocolCommandListener listener)
Adds a ProtocolCommandListener. Delegates this task to _commandSupport_ .- Parameters:
listener- The ProtocolCommandListener to add.
-
removeProtocolCommandistener
public void removeProtocolCommandistener(ProtocolCommandListener listener)
Removes a ProtocolCommandListener. Delegates this task to _commandSupport_ .- Parameters:
listener- The ProtocolCommandListener to remove.
-
disconnect
public void disconnect() throws java.io.IOExceptionCloses 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. The reply text and code information from the last command is voided so that the memory it used may be reclaimed.- Overrides:
disconnectin classTelnetClient- Throws:
java.io.IOException- If an error occurs while disconnecting.
-
sendCommand
public int sendCommand(java.lang.String command, java.lang.String args) throws java.io.IOExceptionSends an FTP command to the server, waits for a reply and returns the numerical response code. After invocation, for more detailed information, the actual reply text can be accessed by calling getReplyString or getReplyStrings .- Parameters:
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.- Returns:
- The integer value of the FTP reply code returned by the server in response to the command.
- Throws:
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.
-
sendCommand
public int sendCommand(int command, java.lang.String args) throws java.io.IOExceptionSends an FTP command to the server, waits for a reply and returns the numerical response code. After invocation, for more detailed information, the actual reply text can be accessed by calling getReplyString or getReplyStrings .- Parameters:
command- The FTPCommand constant 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.- Returns:
- The integer value of the FTP reply code returned by the server in response to the command.
- Throws:
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.
-
sendCommand
public int sendCommand(java.lang.String command) throws java.io.IOExceptionSends an FTP command with no arguments to the server, waits for a reply and returns the numerical response code. After invocation, for more detailed information, the actual reply text can be accessed by calling getReplyString or getReplyStrings .- Parameters:
command- The text representation of the FTP command to send.- Returns:
- The integer value of the FTP reply code returned by the server in response to the command.
- Throws:
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.
-
sendCommand
public int sendCommand(int command) throws java.io.IOExceptionSends an FTP command with no arguments to the server, waits for a reply and returns the numerical response code. After invocation, for more detailed information, the actual reply text can be accessed by calling getReplyString or getReplyStrings .- Parameters:
command- The FTPCommand constant corresponding to the FTP command to send.- Returns:
- The integer value of the FTP reply code returned by the server in response to the command.
- Throws:
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.
-
getReplyCode
public int getReplyCode()
Returns the integer value of the reply code of the last FTP reply. You will usually only use this method after you connect to the FTP server to check that the connection was successful sinceconnectis of type void.- Returns:
- The integer value of the reply code of the last FTP reply.
-
getReply
public int getReply() throws java.io.IOExceptionFetches a reply from the FTP server and returns the integer reply code. After calling this method, the actual reply text can be accessed from either calling 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.- Returns:
- The integer value of the reply code of the fetched FTP reply.
- Throws:
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.
-
getReplyStrings
public java.lang.String[] getReplyStrings()
Returns the lines of text from the last FTP server response as an array of strings, one entry per line. The end of line markers of each are stripped from each line.- Returns:
- The lines of text from the last FTP response as an array.
-
getReplyString
public 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.- Returns:
- The entire text from the last FTP response as a String.
-
user
public int user(java.lang.String username) throws java.io.IOExceptionA convenience method to send the FTP USER command to the server, receive the reply, and return the reply code.- Parameters:
username- The username to login under.- Returns:
- The reply code received from the server.
- Throws:
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.
-
pass
public int pass(java.lang.String password) throws java.io.IOExceptionA convenience method to send the FTP PASS command to the server, receive the reply, and return the reply code.- Parameters:
pass- The plain text password of the username being logged into.- Returns:
- The reply code received from the server.
- Throws:
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.
-
acct
public int acct(java.lang.String account) throws java.io.IOExceptionA convenience method to send the FTP ACCT command to the server, receive the reply, and return the reply code.- Parameters:
account- The account name to access.- Returns:
- The reply code received from the server.
- Throws:
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.
-
abor
public int abor() throws java.io.IOExceptionA convenience method to send the FTP ABOR command to the server, receive the reply, and return the reply code.- Returns:
- The reply code received from the server.
- Throws:
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.
-
cwd
public int cwd(java.lang.String directory) throws java.io.IOExceptionA convenience method to send the FTP CWD command to the server, receive the reply, and return the reply code.- Parameters:
directory- The new working directory.- Returns:
- The reply code received from the server.
- Throws:
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.
-
cdup
public int cdup() throws java.io.IOExceptionA convenience method to send the FTP CDUP command to the server, receive the reply, and return the reply code.- Returns:
- The reply code received from the server.
- Throws:
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.
-
quit
public int quit() throws java.io.IOExceptionA convenience method to send the FTP QUIT command to the server, receive the reply, and return the reply code.- Returns:
- The reply code received from the server.
- Throws:
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.
-
rein
public int rein() throws java.io.IOExceptionA convenience method to send the FTP REIN command to the server, receive the reply, and return the reply code.- Returns:
- The reply code received from the server.
- Throws:
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.
-
smnt
public int smnt(java.lang.String dir) throws java.io.IOExceptionA convenience method to send the FTP SMNT command to the server, receive the reply, and return the reply code.- Parameters:
dir- The directory name.- Returns:
- The reply code received from the server.
- Throws:
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.
-
port
public int port(java.net.InetAddress host, int port) throws java.io.IOExceptionA convenience method to send the FTP PORT command to the server, receive the reply, and return the reply code.- Parameters:
host- The host owning the port.port- The new port.- Returns:
- The reply code received from the server.
- Throws:
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.
-
pasv
public int pasv() throws java.io.IOExceptionA convenience method to send the FTP PASV command to the server, receive the reply, and return the reply code. Remember, it's up to you to interpret the reply string containing the host/port information.- Returns:
- The reply code received from the server.
- Throws:
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.
-
type
public int type(int fileType, int formatOrByteSize) throws java.io.IOExceptionA convenience method to send the FTP TYPE command for text files to the server, receive the reply, and return the reply code.- Parameters:
type- The type of the file (one of theFILE_TYPEconstants).formatOrByteSize- The format of the file (one of the_FORMATconstants. In the case ofLOCAL_FILE_TYPE, the byte size.- Returns:
- The reply code received from the server.
- Throws:
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.
-
type
public int type(int fileType) throws java.io.IOExceptionA convenience method to send the FTP TYPE command to the server, receive the reply, and return the reply code.- Parameters:
type- The type of the file (one of theFILE_TYPEconstants).- Returns:
- The reply code received from the server.
- Throws:
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.
-
stru
public int stru(int structure) throws java.io.IOExceptionA convenience method to send the FTP STRU command to the server, receive the reply, and return the reply code.- Parameters:
structure- The structure of the file (one of the_STRUCTUREconstants).- Returns:
- The reply code received from the server.
- Throws:
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.
-
mode
public int mode(int mode) throws java.io.IOExceptionA convenience method to send the FTP MODE command to the server, receive the reply, and return the reply code.- Parameters:
mode- The transfer mode to use (one of theTRANSFER_MODEconstants).- Returns:
- The reply code received from the server.
- Throws:
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.
-
retr
public int retr(java.lang.String pathname) throws java.io.IOExceptionA convenience method to send the FTP RETR command to the server, receive the reply, and return the reply code. Remember, it is up to you to manage the data connection. If you don't need this low level of access, use FTPClient, which will handle all low level details for you.- Parameters:
pathname- The pathname of the file to retrieve.- Returns:
- The reply code received from the server.
- Throws:
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.
-
stor
public int stor(java.lang.String pathname) throws java.io.IOExceptionA convenience method to send the FTP STOR command to the server, receive the reply, and return the reply code. Remember, it is up to you to manage the data connection. If you don't need this low level of access, use FTPClient, which will handle all low level details for you.- Parameters:
pathname- The pathname to use for the file when stored at the remote end of the transfer.- Returns:
- The reply code received from the server.
- Throws:
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.
-
stou
public int stou() throws java.io.IOExceptionA convenience method to send the FTP STOU command to the server, receive the reply, and return the reply code. Remember, it is up to you to manage the data connection. If you don't need this low level of access, use FTPClient, which will handle all low level details for you.- Returns:
- The reply code received from the server.
- Throws:
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.
-
stou
public int stou(java.lang.String filename) throws java.io.IOExceptionA convenience method to send the FTP STOU command to the server, receive the reply, and return the reply code. Remember, it is up to you to manage the data connection. If you don't need this low level of access, use FTPClient, which will handle all low level details for you.- Parameters:
pathname- The base pathname to use for the file when stored at the remote end of the transfer. Some FTP servers require this.- Returns:
- The reply code received from the server.
- Throws:
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.
-
appe
public int appe(java.lang.String pathname) throws java.io.IOExceptionA convenience method to send the FTP APPE command to the server, receive the reply, and return the reply code. Remember, it is up to you to manage the data connection. If you don't need this low level of access, use FTPClient, which will handle all low level details for you.- Parameters:
pathname- The pathname to use for the file when stored at the remote end of the transfer.- Returns:
- The reply code received from the server.
- Throws:
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.
-
allo
public int allo(int bytes) throws java.io.IOExceptionA convenience method to send the FTP ALLO command to the server, receive the reply, and return the reply code.- Parameters:
bytes- The number of bytes to allocate.- Returns:
- The reply code received from the server.
- Throws:
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.
-
allo
public int allo(int bytes, int recordSize) throws java.io.IOExceptionA convenience method to send the FTP ALLO command to the server, receive the reply, and return the reply code.- Parameters:
bytes- The number of bytes to allocate.recordSize- The size of a record.- Returns:
- The reply code received from the server.
- Throws:
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.
-
rest
public int rest(java.lang.String marker) throws java.io.IOExceptionA convenience method to send the FTP REST command to the server, receive the reply, and return the reply code.- Parameters:
marker- The marker at which to restart a transfer.- Returns:
- The reply code received from the server.
- Throws:
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.
-
rnfr
public int rnfr(java.lang.String pathname) throws java.io.IOExceptionA convenience method to send the FTP RNFR command to the server, receive the reply, and return the reply code.- Parameters:
pathname- The pathname to rename from.- Returns:
- The reply code received from the server.
- Throws:
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.
-
rnto
public int rnto(java.lang.String pathname) throws java.io.IOExceptionA convenience method to send the FTP RNTO command to the server, receive the reply, and return the reply code.- Parameters:
pathname- The pathname to rename to- Returns:
- The reply code received from the server.
- Throws:
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.
-
dele
public int dele(java.lang.String pathname) throws java.io.IOExceptionA convenience method to send the FTP DELE command to the server, receive the reply, and return the reply code.- Parameters:
pathname- The pathname to delete.- Returns:
- The reply code received from the server.
- Throws:
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.
-
rmd
public int rmd(java.lang.String pathname) throws java.io.IOExceptionA convenience method to send the FTP RMD command to the server, receive the reply, and return the reply code.- Parameters:
pathname- The pathname of the directory to remove.- Returns:
- The reply code received from the server.
- Throws:
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.
-
mkd
public int mkd(java.lang.String pathname) throws java.io.IOExceptionA convenience method to send the FTP MKD command to the server, receive the reply, and return the reply code.- Parameters:
pathname- The pathname of the new directory to create.- Returns:
- The reply code received from the server.
- Throws:
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.
-
pwd
public int pwd() throws java.io.IOExceptionA convenience method to send the FTP PWD command to the server, receive the reply, and return the reply code.- Returns:
- The reply code received from the server.
- Throws:
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.
-
list
public int list() throws java.io.IOExceptionA convenience method to send the FTP LIST command to the server, receive the reply, and return the reply code. Remember, it is up to you to manage the data connection. If you don't need this low level of access, use FTPClient, which will handle all low level details for you.- Returns:
- The reply code received from the server.
- Throws:
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.
-
list
public int list(java.lang.String pathname) throws java.io.IOExceptionA convenience method to send the FTP LIST command to the server, receive the reply, and return the reply code. Remember, it is up to you to manage the data connection. If you don't need this low level of access, use FTPClient, which will handle all low level details for you.- Parameters:
pathname- The pathname to list.- Returns:
- The reply code received from the server.
- Throws:
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.
-
nlst
public int nlst() throws java.io.IOExceptionA convenience method to send the FTP NLST command to the server, receive the reply, and return the reply code. Remember, it is up to you to manage the data connection. If you don't need this low level of access, use FTPClient, which will handle all low level details for you.- Returns:
- The reply code received from the server.
- Throws:
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.
-
nlst
public int nlst(java.lang.String pathname) throws java.io.IOExceptionA convenience method to send the FTP NLST command to the server, receive the reply, and return the reply code. Remember, it is up to you to manage the data connection. If you don't need this low level of access, use FTPClient, which will handle all low level details for you.- Parameters:
pathname- The pathname to list.- Returns:
- The reply code received from the server.
- Throws:
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.
-
site
public int site(java.lang.String parameters) throws java.io.IOExceptionA convenience method to send the FTP SITE command to the server, receive the reply, and return the reply code.- Parameters:
parameters- The site parameters to send.- Returns:
- The reply code received from the server.
- Throws:
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.
-
syst
public int syst() throws java.io.IOExceptionA convenience method to send the FTP SYST command to the server, receive the reply, and return the reply code.- Returns:
- The reply code received from the server.
- Throws:
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.
-
stat
public int stat() throws java.io.IOExceptionA convenience method to send the FTP STAT command to the server, receive the reply, and return the reply code.- Returns:
- The reply code received from the server.
- Throws:
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.
-
stat
public int stat(java.lang.String pathname) throws java.io.IOExceptionA convenience method to send the FTP STAT command to the server, receive the reply, and return the reply code.- Parameters:
pathname- A pathname to list.- Returns:
- The reply code received from the server.
- Throws:
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.
-
help
public int help() throws java.io.IOExceptionA convenience method to send the FTP HELP command to the server, receive the reply, and return the reply code.- Returns:
- The reply code received from the server.
- Throws:
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.
-
help
public int help(java.lang.String command) throws java.io.IOExceptionA convenience method to send the FTP HELP command to the server, receive the reply, and return the reply code.- Parameters:
command- The command name on which to request help.- Returns:
- The reply code received from the server.
- Throws:
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.
-
noop
public int noop() throws java.io.IOExceptionA convenience method to send the FTP NOOP command to the server, receive the reply, and return the reply code.- Returns:
- The reply code received from the server.
- Throws:
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.
-
-