org.finj
Class FTPClient

java.lang.Object
  extended by org.finj.FTPClient

public class FTPClient
extends java.lang.Object

The main class of the project, the one to instanciate in order to have access to an FTP server through FinJ. FIXME : mention default values.

Copyright (C) 2000-2008 Javier Iglesias.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Version:
$Id: FTPClient.java 55 2009-07-15 22:39:49Z jiglesias $
Author:
Javier Iglesias -- jiglesias@users.sourceforge.net

Constructor Summary
FTPClient()
          Constructs a new instance of this class.
FTPClient(java.util.Locale locale)
          Constructs a new instance of this class using the provided Locale for internationalization of FTPResponses.
FTPClient(java.lang.String server)
          Constructs a new instance of this class that will try to connect to the server through the FTPConstants.DEFAULT_FTP_PORT.
FTPClient(java.lang.String server, int port)
          Constructs a new instance of this class that will try to connect to the server througn the provided port.
FTPClient(java.lang.String server, int port, java.util.Locale locale)
          Constructs a new instance of this class that will try to connect to the server througn the provided port.
FTPClient(java.lang.String server, int port, java.lang.String user, char[] pass)
          Constructs a new instance of this class that will try to connect to the server through the provided port, and try to log in using user and pass login information.
FTPClient(java.lang.String server, int port, java.lang.String user, char[] pass, java.util.Locale locale)
          Constructs a new instance of this class that will try to connect to the server through the provided port, and try to log in using user and pass login information.
FTPClient(java.lang.String server, java.util.Locale locale)
          Constructs a new instance of this class that will try to connect to the server through the FTPConstants.DEFAULT_FTP_PORT.
FTPClient(java.lang.String server, java.lang.String user, char[] pass)
          Constructs a new instance of this class that will try to connect to the server through the FTPConstants.DEFAULT_FTP_PORT, and try to log in using user and pass login information.
FTPClient(java.lang.String server, java.lang.String user, char[] pass, java.util.Locale locale)
          Constructs a new instance of this class that will try to connect to the server through the FTPConstants.DEFAULT_FTP_PORT, and try to log in using user and pass login information.
 
Method Summary
 void abortCommand()
          This command tells the server to abort the previous FTP service command and any associated transfer of data.
 void allocateSpace(int bytes)
          This command may be required by some servers to reserve sufficient storage to accomodate the new file to be transferred.
 void allocateSpace(int space, int size)
          This command works just as allocateSpace (int), except that it allows to set a second (optional) parameter that may be required for files sent with record or page structure : a maximum record or page size.
 void appendToFile(java.io.InputStream data, java.lang.String pathname)
          This command causes the server-DTP to accept the data transferred and to store the data in a file at the server site.
 void appendToFile(java.io.InputStream data, java.lang.String pathname, boolean passive)
          This command causes the server-DTP to accept the data transferred and to store the data in a file at the server site.
 void ascii()
          Deprecated. use FTPClient.setDataType (FTPConstants.ASCII_DATA_TYPE) instead. THIS METHOD WILL NOT BE CONTINUED.
 void binary()
          Deprecated. use FTPClient.setDataType (FTPConstants.IMAGE_DATA_TYPE) instead. THIS METHOD WILL NOT BE CONTINUED.
protected  void broadcastCommand(java.lang.String command)
          Broadcasts the command sent to the server to the current observer, if any.
protected  void broadcastResponse(FTPResponse response)
          Broadcasts the response received from the server to the current observer, if any.
 void cd(java.lang.String pathname)
          Deprecated. use FTPClient.setWorkingDirectory (String) instead. THIS METHOD WILL NOT BE CONTINUED.
 boolean checkConnection()
          This command does not affect any parameters or previously entered commands.
 void close()
          This method terminates a user and if file transfer is not in progress, the server closes the control connection.
 void closeServer()
          Deprecated. use FTPClient.close () instead. THIS METHOD WILL NOT BE CONTINUED.
protected  void dataReceived(int bytes)
          Broadcasts the amount of data received from the server to the observer, if any.
protected  void dataSent(int bytes)
          Broadcasts the amount of data received from the server to the observer, if any.
 void deleteFile(java.lang.String pathname)
          This command causes the file specified as the pathname parameter to be deleted at the server site.
 java.lang.String doSite(java.lang.String command)
          This command is used by the server to provide services specific to his system that are essential to file transfer but not sufficiently universal to be included as commands in the protocol.
 sun.net.TelnetInputStream get(java.lang.String pathname)
          Deprecated. use FTPClient.getFile (String) instead. THIS METHOD WILL NOT BE CONTINUED.
 int getDataStructure()
          Returns the current data structure manipulated, that is one of FTPConstants.FILE_DATA_STRUCTURE (default value), FTPConstants.RECORD_DATA_STRUCTURE, FTPConstants.PAGE_DATA_STRUCTURE.
 int getDataTransferMode()
          Returns the data transmission mode currently used, that is one of FTPConstants.STREAM_DATA_TRANSMISSION_MODE (default value), FTPConstants.BLOCK_DATA_TRANSMISSION_MODE, FTPConstants.COMPRESSED_DATA_TRANSMISSION_MODE.
 int getDataType()
          Returns the current data type manipulated, that is one of FTPConstants.ASCII_DATA_TYPE (default value), FTPConstants.EBCDIC_DATA_TYPE, FTPConstants.IMAGE_DATA_TYPE, FTPConstants.LOCAL_DATA_TYPE.
 void getFile(java.io.OutputStream destination, java.lang.String pathname)
          This command causes the server-DTP to transfer a copy of the file, specified in the pathname, to this client.
 void getFile(java.io.OutputStream destination, java.lang.String pathname, boolean passive)
          This command causes the server-DTP to transfer a copy of the file, specified in the pathname, to this client.
 RemoteFile[] getFileDescriptors()
          Returns the complete description of the files in the current working directory.
 RemoteFile[] getFileDescriptors(boolean passive)
          Returns the complete description of the files in the current working directory.
 RemoteFile[] getFileDescriptors(java.lang.String pathname)
          Returns the complete description of the files in the directory specified by the path argument.
 RemoteFile[] getFileDescriptors(java.lang.String pathname, boolean passive)
          Returns the complete description of the files in the directory specified by the path argument.
 void getFileFrom(java.io.OutputStream destination, java.lang.String pathname, int position)
          The position argument field represents the server marker at which file transfer is to be restarted.
 java.lang.String[] getFileNames()
          Returns a directory listing for the current working directory.
 java.lang.String[] getFileNames(boolean passive)
          Returns a directory listing for the current working directory.
 java.lang.String[] getFileNames(java.lang.String pathname)
          Returns a directory listing for the path provided as parameter.
 java.lang.String[] getFileNames(java.lang.String pathname, boolean passive)
          Returns a directory listing for the path provided as parameter.
 FTPClientObserver getObserver()
          Returns the current observer of this instance.
 java.lang.String[] getServerStatus()
          Returns the status response from the server.
 java.lang.String[] getServerStatus(java.lang.String pathname)
          Returns the status response from the server.
 java.lang.String getServerSystemName()
          Returns the type of operating system at the server, one of the system names listed in the current version of the 'Assigned Numbers Document' (as of 31-jul-00 : RFC1700).
 java.lang.String getWorkingDirectory()
          This command causes the name of the current working directory to be returned.
 boolean hasObserver()
          Tells if this instance is currently being observed.
 boolean isConnected()
          Returns true if a control connection is currently opened between this client and a FTP server, false else.
protected  void isConnected(boolean isIt)
          Sets the current status of the control connection to the value provided as parameter.
 boolean isVerbose()
          Return the current status of the verbose (debugging) mode.
 void isVerbose(boolean isIt)
          Update verbose (debugging) mode status.
 void login(java.lang.String user, char[] pass)
          Log to the current server using the provided login information.
 void logout()
          This method terminates a user, flushing all I/O and account information, except to allow any transfer in progress to be completed.
 void makeDirectory(java.lang.String pathname)
          This command causes the directory specified in the pathname to be created as a directory (if the pathname is absolute) or as a subdirectory of the current working directory (if the pathname is relative).
 void mountStructure(java.lang.String system)
          This command allows the user to mount a different file system data structure without altering his login or accounting information.
protected  java.lang.String notValidResponse(int code, java.lang.String cmd)
          Utility routine that composes the message used for FTPExceptions.
 void open(java.lang.String server)
          Connects to the server through the FTPConstants.DEFAULT_FTP_PORT.
 void open(java.lang.String server, int port)
          Connects to the server through the provided port.
 void openServer(java.lang.String server)
          Deprecated. use FTPClient.open (String) instead. THIS METHOD WILL NOT BE CONTINUED.
 void openServer(java.lang.String server, int port)
          Deprecated. use FTPClient.open (String, int) instead. THIS METHOD WILL NOT BE CONTINUED.
protected  FTPResponse processCommand(FTPCommand command)
          Do all the job required when processing an FTP command, returning the last response received from the server.
protected  FTPResponse processPostCommand(FTPCommand command)
          Do all the job required when processing an FTP command, returning the last response received from the server.
 sun.net.TelnetOutputStream put(java.lang.String pathname)
          Deprecated. use FTPClient.putFile (InputStream, String) instead. THIS METHOD WILL NOT BE CONTINUED.
 void putFile(java.io.InputStream data, java.lang.String pathname)
          This command causes the server-DTP to accept the data transferred and to store the data as a file at the server site.
 void putFile(java.io.InputStream data, java.lang.String pathname, boolean passive)
          This command causes the server-DTP to accept the data transferred and to store the data as a file at the server site.
 java.lang.String putUniqueFile(java.io.InputStream data)
          This command behaves like putFile (InputStream, String) except that the resultant file is to be created in the current directory nder a name unique to that directory.
 java.lang.String putUniqueFile(java.io.InputStream data, boolean passive)
          This command behaves like putFile (InputStream, String) except that the resultant file is to be created in the current directory nder a name unique to that directory.
protected  FTPResponse readFTPResponse()
          Reads replies sent by FTP server on the control stream and notifies the observer (if it exists).
protected  java.lang.String readLineFromControlConnection()
          Reads a line from the control connection and returns it without any change.
 void removeDirectory(java.lang.String pathname)
          This command causes the directory specified in the pathname to be removed as a directory (if the pathname is absolute) or as a subdirectory of the current working directory (if the pathname is relative).
 void removeObserver()
          Removes the current observer of this instance, if any.
 void renameFile(java.lang.String from, java.lang.String to)
          This command causes a file to be renamed from its old pathname to its new pathname.
protected  void sendFTPCommand(java.lang.String command)
          Writes the command to the control stream and nofifies the observer (if it exists).
 void setAccount(java.lang.String account)
          The account data is used to indentify user's account, but is not necessarily related to the username used to log in, as some sites may require an account for login and others only for specific access, such as storing files.
 void setDataPort(byte host_1, byte host_2, byte host_3, byte host_4, byte port_1, byte port_2)
          Defines the HOST-PORT specification for the data port to be used in data connection.
 void setDataPort(int host, short port)
          Defines the HOST-PORT specification for the data port to be used in data connection.
 void setDataPort(short port)
          Defines the HOST-PORT specification for the data port to be used in data connection.
 void setDataStructure(int structure)
          In addition to different representation types, FTP allows the structure of a file to be specified.
 void setDataTransferMode(int mode)
          There are three transmission mode available, one which formats the data and allows for restart procedures; one which also compresses the data for efficient transfer; and one which passes the data with little or no processing.
 void setDataType(int type)
          Data representations are handled in FTP by a user specifying a representation type.
 void setDataType(int type, int bytes)
          Works just as setDataType (int), except that if the type is FTPConstants.LOCAL_DATA_TYPE, then the second parameter (which is useless for the other types) must be the "logical byte size".
 void setObserver(FTPClientObserver observer)
          Sets the observer of this object to be the one passed as parameter.
 void setWorkingDirectory(java.lang.String pathname)
          This command allows the user to work with a different directory or dataset for file storage or retrieval without altering his login of accounting information.
 void setWorkingDirectoryUp()
          This command is a special case of setWorkingDirectory (String), and is included to simplify the implementation of programs for transferring directory trees between operating systems having different syntaxes for naming the parent directory.
protected  byte[] toByteArray(int value)
          Utility routine that takes an int value and chops it into a 4 bytes array.
protected  byte[] toByteArray(short value)
          Utility routine that takes a short value and chops it into a 2 bytes array.
protected  int toInt(byte[] value)
          Utility routine that takes a byte array value and links it into an int value.
protected  short toUnsignedShort(byte value)
          Utility routine that takes a byte value and transcripts it into a short value.
 boolean usePassiveDataTransfer()
          Returns the true if data transfers are done in passive mode.
 void usePassiveDataTransfer(boolean isIt)
          Turns passive data transfer mode on and off.
protected  void writeLineToControlConnection(java.lang.String line)
          Writes a line to the control connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FTPClient

public FTPClient()
Constructs a new instance of this class.

Since:
v1.0

FTPClient

public FTPClient(java.util.Locale locale)
Constructs a new instance of this class using the provided Locale for internationalization of FTPResponses. If avaiable. Talking about availability, if you have some time (ca. 10 minutes !) you might translate the 40 (!) sentences into your own language. Just e-mail me to jiglesias@users.sourceforge.net. MANY THANKS IN ADVANCE !

Parameters:
locale - used for internationalization of FTPResponse messages.
Since:
v1.0

FTPClient

public FTPClient(java.lang.String server)
          throws java.io.IOException,
                 FTPException
Constructs a new instance of this class that will try to connect to the server through the FTPConstants.DEFAULT_FTP_PORT.

Parameters:
server - DNS name or IP number of the FTP server to connect to.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0

FTPClient

public FTPClient(java.lang.String server,
                 java.util.Locale locale)
          throws java.io.IOException,
                 FTPException
Constructs a new instance of this class that will try to connect to the server through the FTPConstants.DEFAULT_FTP_PORT.

Parameters:
server - DNS name or IP number of the FTP server to connect to.
locale - used for internationalization of FTPResponse messages.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0

FTPClient

public FTPClient(java.lang.String server,
                 int port)
          throws java.io.IOException,
                 FTPException
Constructs a new instance of this class that will try to connect to the server througn the provided port.

Parameters:
server - DNS name or IP number of the FTP server to connect to.
port - TCP port number to use for the control connection.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0

FTPClient

public FTPClient(java.lang.String server,
                 int port,
                 java.util.Locale locale)
          throws java.io.IOException,
                 FTPException
Constructs a new instance of this class that will try to connect to the server througn the provided port.

Parameters:
server - DNS name or IP number of the FTP server to connect to.
port - TCP port number to use for the control connection.
locale - used for internationalization of FTPResponse messages.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0

FTPClient

public FTPClient(java.lang.String server,
                 java.lang.String user,
                 char[] pass)
          throws java.io.IOException,
                 FTPException
Constructs a new instance of this class that will try to connect to the server through the FTPConstants.DEFAULT_FTP_PORT, and try to log in using user and pass login information. It is recommended that the character array be cleared after use by setting each character to zero.

Parameters:
server - DNS name or IP number of the FTP server to connect to.
user - User name indentifier to use to log in.
pass - Password to use to log in.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available, refuses connections or login information.
Since:
v1.0.2

FTPClient

public FTPClient(java.lang.String server,
                 java.lang.String user,
                 char[] pass,
                 java.util.Locale locale)
          throws java.io.IOException,
                 FTPException
Constructs a new instance of this class that will try to connect to the server through the FTPConstants.DEFAULT_FTP_PORT, and try to log in using user and pass login information. It is recommended that the character array be cleared after use by setting each character to zero.

Parameters:
server - DNS name or IP number of the FTP server to connect to.
user - User name indentifier to use to log in.
pass - Password to use to log in.
locale - used for internationalization of FTPResponse messages.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available, refuses connections or login information.
Since:
v1.0.2

FTPClient

public FTPClient(java.lang.String server,
                 int port,
                 java.lang.String user,
                 char[] pass)
          throws java.io.IOException,
                 FTPException
Constructs a new instance of this class that will try to connect to the server through the provided port, and try to log in using user and pass login information. It is recommended that the character array be cleared after use by setting each character to zero.

Parameters:
server - DNS name or IP number of the FTP server to connect to.
port - TCP port number to use for the control connection.
user - User name indentifier to use to log in.
pass - Password to use to log in.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available, refuses connections or login information.
Since:
v1.0.2

FTPClient

public FTPClient(java.lang.String server,
                 int port,
                 java.lang.String user,
                 char[] pass,
                 java.util.Locale locale)
          throws java.io.IOException,
                 FTPException
Constructs a new instance of this class that will try to connect to the server through the provided port, and try to log in using user and pass login information. It is recommended that the character array be cleared after use by setting each character to zero.

Parameters:
server - DNS name or IP number of the FTP server to connect to.
port - TCP port number to use for the control connection.
user - User name indentifier to use to log in.
pass - Password to use to log in.
locale - used for internationalization of FTPResponse messages.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available, refuses connections or login information.
Since:
v1.0.2
Method Detail

isVerbose

public boolean isVerbose()
Return the current status of the verbose (debugging) mode.

Returns:
true if verbose mode is on, false if off.
Since:
v1.0
See Also:
isVerbose(boolean)

isVerbose

public void isVerbose(boolean isIt)
Update verbose (debugging) mode status.

Parameters:
isIt - should verbose mode be activated?
Since:
v1.0
See Also:
isVerbose()

setObserver

public void setObserver(FTPClientObserver observer)
Sets the observer of this object to be the one passed as parameter. In order to keep the class thread safe (and because I don't see any reason to have more than one observer), only one FTPClientObserver is allowed per FTPClient

Parameters:
observer - new observer for this instance.
Since:
v1.0
See Also:
hasObserver(), getObserver(), removeObserver()

hasObserver

public boolean hasObserver()
Tells if this instance is currently being observed.

Returns:
true if this is being observed.
Since:
v1.0
See Also:
setObserver(FTPClientObserver), getObserver(), removeObserver()

getObserver

public FTPClientObserver getObserver()
Returns the current observer of this instance. In order to keep the class thread safe (and because I don't see any reason to have more than one observer), only one FTPClientObserver is allowed per FTPClient

Returns:
current observer for this instance.
Since:
v1.0
See Also:
setObserver(FTPClientObserver), hasObserver(), removeObserver()

removeObserver

public void removeObserver()
Removes the current observer of this instance, if any. In order to keep the class thread safe (and because I don't see any reason to have more than one observer), only one FTPClientObserver is allowed per FTPClient

Since:
v1.0
See Also:
setObserver(FTPClientObserver), hasObserver(), getObserver()

broadcastResponse

protected void broadcastResponse(FTPResponse response)
Broadcasts the response received from the server to the current observer, if any.

Parameters:
response - response to command received from server
Since:
v1.0

broadcastCommand

protected void broadcastCommand(java.lang.String command)
Broadcasts the command sent to the server to the current observer, if any.

Parameters:
command - string sent to server
Since:
v1.0

dataReceived

protected void dataReceived(int bytes)
Broadcasts the amount of data received from the server to the observer, if any.

Parameters:
bytes - amount of data received from server
Since:
v1.0
See Also:
dataSent(int)

dataSent

protected void dataSent(int bytes)
Broadcasts the amount of data received from the server to the observer, if any.

Parameters:
bytes - amount of data sent to server
Since:
v1.0
See Also:
dataReceived(int)

processCommand

protected FTPResponse processCommand(FTPCommand command)
                              throws java.io.IOException,
                                     FTPException
Do all the job required when processing an FTP command, returning the last response received from the server.

Parameters:
command - FTP command to execute
Returns:
last response received from server.
Throws:
FTPException - something goes wrong with FTP codes
java.io.IOException - something goes wrong with the sockets, streams, ...
Since:
v1.2

processPostCommand

protected FTPResponse processPostCommand(FTPCommand command)
                                  throws java.io.IOException,
                                         FTPException
Do all the job required when processing an FTP command, returning the last response received from the server.

Parameters:
command - FTP command to execute
Returns:
last response received from server.
Throws:
FTPException - something goes wrong with FTP codes
java.io.IOException - something goes wrong with the sockets, streams, ...
Since:
v1.2

sendFTPCommand

protected void sendFTPCommand(java.lang.String command)
                       throws java.io.IOException
Writes the command to the control stream and nofifies the observer (if it exists).

Parameters:
command - FTP command to execute
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
Since:
v1.0

readFTPResponse

protected FTPResponse readFTPResponse()
                               throws java.io.IOException
Reads replies sent by FTP server on the control stream and notifies the observer (if it exists).

Returns:
FTPResponse representation of server's response.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
Since:
v1.0
See Also:
"RFC959-4:2"

writeLineToControlConnection

protected void writeLineToControlConnection(java.lang.String line)
                                     throws java.io.IOException
Writes a line to the control connection. Usual methods won't call this method directly, but through sendFTPCommand(String).

Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
Since:
v1.0
See Also:
sendFTPCommand(String)

readLineFromControlConnection

protected java.lang.String readLineFromControlConnection()
                                                  throws java.io.IOException
Reads a line from the control connection and returns it without any change. Usual methods won't call this method directly, but through readFTPResponse.

Returns:
FTPResponse representation of server's response.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
Since:
v1.0
See Also:
readFTPResponse()

open

public void open(java.lang.String server)
          throws java.io.IOException,
                 FTPException,
                 java.net.UnknownHostException
Connects to the server through the FTPConstants.DEFAULT_FTP_PORT.

Parameters:
server - DNS name or IP number of the FTP server to connect to.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
java.net.UnknownHostException - host doesn't exist.
Since:
v1.0
See Also:
open(String,int)

open

public void open(java.lang.String server,
                 int port)
          throws java.io.IOException,
                 FTPException,
                 java.net.UnknownHostException
Connects to the server through the provided port.

Parameters:
server - DNS name or IP number of the FTP server to connect to.
port - TCP port number to use for the control connection.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
java.net.UnknownHostException - host doesn't exist.
Since:
v1.0
See Also:
open(String)

isConnected

public boolean isConnected()
Returns true if a control connection is currently opened between this client and a FTP server, false else.

Returns:
current status of the control connection.
Since:
v1.0

isConnected

protected void isConnected(boolean isIt)
Sets the current status of the control connection to the value provided as parameter.

Parameters:
isIt - value to answer to the isConnected () method calls.
Since:
v1.0
See Also:
isConnected()

login

public void login(java.lang.String user,
                  char[] pass)
           throws java.io.IOException,
                  FTPException
Log to the current server using the provided login information. This is the first method to call on a server just after connecting to it. It is recommended that the character array be cleared after use by setting each character to zero.

Parameters:
user - User name indentifier to use to log in.
pass - Password to use to log in.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available, refuses connections or login information.
Since:
v1.0
See Also:
"RFC959-4:1:1:'USER'", "RFC959-4:1:1:'PASS'"

setAccount

public void setAccount(java.lang.String account)
                throws java.io.IOException,
                       FTPException
The account data is used to indentify user's account, but is not necessarily related to the username used to log in, as some sites may require an account for login and others only for specific access, such as storing files. In the latter, the command may arrive at any time.

Parameters:
account - Account data used to identify user.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available, refuses connections or account information.
Since:
v1.0
See Also:
"RFC959-4:1:1:'ACCT'"

logout

public void logout()
            throws java.io.IOException,
                   FTPException
This method terminates a user, flushing all I/O and account information, except to allow any transfer in progress to be completed. All parameters are reset to the default settings and the control connection is left open, leaving the control connection in the identical state which a user finds himself immediately after the control connection is opened using one of the open methods. A login call may be expected to follow. If no login call is supposed to be taken after this method, then close may be a better guess.

Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available, refuses connections or account information.
Since:
v1.0
See Also:
close(), "RFC959-4:1:1:'REIN'"

setDataPort

public void setDataPort(short port)
                 throws java.io.IOException,
                        FTPException
Defines the HOST-PORT specification for the data port to be used in data connection. There are defaults for both the user and server data ports, and under normal circumstances this command and its response are not needed. IF this command is used, the argument is the concatenation of a 32-bit internet host address and a 16-bit TCP port address.

Parameters:
port - 16-bits TCP port number to use for the data connection.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
setDataPort(int,short), setDataPort(byte,byte,byte,byte,byte,byte), "RFC959-4:1:2:'PORT'"

setDataPort

public void setDataPort(int host,
                        short port)
                 throws java.io.IOException,
                        FTPException
Defines the HOST-PORT specification for the data port to be used in data connection. There are defaults for both the user and server data ports, and under normal circumstances this command and its response are not needed. IF this command is used, the argument is the concatenation of a 32-bit internet host address and a 16-bit TCP port address.

Parameters:
host - 32-bits IP host address to use for the data connection.
port - 16-bits TCP port number to use for the data connection.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
setDataPort(short), setDataPort(byte,byte,byte,byte,byte,byte), "RFC959-4:1:2:'PORT'"

setDataPort

public void setDataPort(byte host_1,
                        byte host_2,
                        byte host_3,
                        byte host_4,
                        byte port_1,
                        byte port_2)
                 throws java.io.IOException,
                        FTPException
Defines the HOST-PORT specification for the data port to be used in data connection. There are defaults for both the user and server data ports, and under normal circumstances this command and its response are not needed. IF this command is used, the argument is the concatenation of a 32-bit internet host address and a 16-bit TCP port address.

Parameters:
host_1 - bits 1 to 8 of IP host address to use for the data connection.
host_2 - bits 9 to 16 of IP host address to use for the data connection.
host_3 - bits 17 to 24 of IP host address to use for the data connection.
host_4 - bits 25 to 32 of IP host address to use for the data connection.
port_1 - bits 1 to 8 of TCP port number to use for the data connection.
port_2 - bits 9 to 16 of TCP port number to use for the data connection.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
setDataPort(short), setDataPort(int,short), "RFC959-4:1:2:'PORT'"

getDataType

public int getDataType()
Returns the current data type manipulated, that is one of FTPConstants.ASCII_DATA_TYPE (default value), FTPConstants.EBCDIC_DATA_TYPE, FTPConstants.IMAGE_DATA_TYPE, FTPConstants.LOCAL_DATA_TYPE.

Returns:
current data type manipulated.
Since:
v1.0
See Also:
setDataType(int), setDataType(int,int)

setDataType

public void setDataType(int type)
                 throws java.io.IOException,
                        FTPException,
                        java.lang.IllegalArgumentException
Data representations are handled in FTP by a user specifying a representation type. This type may implicitly (as ASCII or EBCDIC) or explicitly (as in Local byte) define a byte size for interpretation which is referred to as the "logical byte size". Note that this has nothing to do with the byte size used for transmission over the data connection, called the "transfer byte size", and the two should not be confused.

Parameters:
type - one of FTPConstants.ASCII_DATA_TYPE (default value), FTPConstants.EBCDIC_DATA_TYPE, FTPConstants.IMAGE_DATA_TYPE, FTPConstants.LOCAL_DATA_TYPE.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
java.lang.IllegalArgumentException - type is not one of those allowed, or a parameter is missing.
Since:
v1.0
See Also:
setDataType(int,int), getDataType(), "RFC959-3:1:1:Data types", "RFC959-4:1:2:'TYPE'"

setDataType

public void setDataType(int type,
                        int bytes)
                 throws java.io.IOException,
                        FTPException,
                        java.lang.IllegalArgumentException
Works just as setDataType (int), except that if the type is FTPConstants.LOCAL_DATA_TYPE, then the second parameter (which is useless for the other types) must be the "logical byte size".

Parameters:
type - usually FTPConstants.LOCAL_DATA_TYPE, or the second parameter will be dummy.
bytes - useless for all types except FTPConstants.LOCAL_DATA_TYPE when it sets the "logical byte size".
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
java.lang.IllegalArgumentException - type is not one of those allowed.
Since:
v1.0
See Also:
setDataType(int), getDataType(), "RFC959-3:1:1:Data types", "RFC959-4:1:2:'TYPE'"

getDataStructure

public int getDataStructure()
Returns the current data structure manipulated, that is one of FTPConstants.FILE_DATA_STRUCTURE (default value), FTPConstants.RECORD_DATA_STRUCTURE, FTPConstants.PAGE_DATA_STRUCTURE.

Returns:
current data structure manipulated.
Since:
v1.0
See Also:
setDataStructure(int)

setDataStructure

public void setDataStructure(int structure)
                      throws java.io.IOException,
                             FTPException,
                             java.lang.IllegalArgumentException
In addition to different representation types, FTP allows the structure of a file to be specified. Both FILE and RECORD structures are accepted for "text" files.

Parameters:
structure - one of FTPConstants.FILE_DATA_STRUCTURE (default value), FTPConstants.RECORD_DATA_STRUCTURE, FTPConstants.PAGE_DATA_STRUCTURE.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
java.lang.IllegalArgumentException - structure is not one of those allowed.
Since:
v1.0
See Also:
getDataStructure(), "RFC959-3:1:2:Data structures", "RFC959-4:1:2:'STRU'"

getDataTransferMode

public int getDataTransferMode()
Returns the data transmission mode currently used, that is one of FTPConstants.STREAM_DATA_TRANSMISSION_MODE (default value), FTPConstants.BLOCK_DATA_TRANSMISSION_MODE, FTPConstants.COMPRESSED_DATA_TRANSMISSION_MODE.

Returns:
current data transmission mode used.
Since:
v1.0
See Also:
setDataTransferMode(int)

setDataTransferMode

public void setDataTransferMode(int mode)
                         throws java.io.IOException,
                                FTPException,
                                java.lang.IllegalArgumentException
There are three transmission mode available, one which formats the data and allows for restart procedures; one which also compresses the data for efficient transfer; and one which passes the data with little or no processing. in this last case the mode interacts with the structure attribute to determine the type of processing. In the compressed mode, the representation type determines the filler byte.

Parameters:
mode - one of FTPConstants.STREAM_DATA_TRANSMISSION_MODE (default value), FTPConstants.BLOCK_DATA_TRANSMISSION_MODE, FTPConstants.COMPRESSED_DATA_TRANSMISSION_MODE.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
java.lang.IllegalArgumentException
Since:
v1.0
See Also:
getDataTransferMode(), "RFC959-3:4:Transmission modes", "RFC959-4:1:2:'MODE'"

usePassiveDataTransfer

public void usePassiveDataTransfer(boolean isIt)
Turns passive data transfer mode on and off.

Parameters:
isIt - change passive status to this value.
Since:
v1.0.2
See Also:
"RFC959-4:1:2:'PASV'"

usePassiveDataTransfer

public boolean usePassiveDataTransfer()
Returns the true if data transfers are done in passive mode.

Returns:
true when data connections to server are done in passive mode.
Since:
v1.0.2
See Also:
"RFC959-4:1:2:'PASV'"

close

public void close()
           throws java.io.IOException,
                  FTPException
This method terminates a user and if file transfer is not in progress, the server closes the control connection. If file transfer is in progress, the connection will remain open for result response and the server will then close it. If the user-process is transferring files for several users, but does not wish to close and then reopen connections for each, the logout followed by the login methods should be called instead.

Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
logout(), "RFC959-4:1:1:'QUIT'"

getFileNames

public java.lang.String[] getFileNames()
                                throws java.io.IOException,
                                       FTPException
Returns a directory listing for the current working directory.

Returns:
list of names of files in the directory.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
getFileNames(String), getFileNames(boolean), getFileNames(String,boolean), "RFC959-4:1:3:'NLST'"

getFileNames

public java.lang.String[] getFileNames(boolean passive)
                                throws java.io.IOException,
                                       FTPException
Returns a directory listing for the current working directory. Value of passive will override the one returned by usePassiveDataTransfer().

Parameters:
passive - give true to use passive data transfer.
Returns:
list of names of files in the directory.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0.2
See Also:
getFileNames(), getFileNames(String), getFileNames(String,boolean), "RFC959-4:1:3:'NLST'", "RFC959-4:1:2:'PASV'"

getFileNames

public java.lang.String[] getFileNames(java.lang.String pathname)
                                throws java.io.IOException,
                                       FTPException
Returns a directory listing for the path provided as parameter. An empty String argument implies the current directory.

Parameters:
pathname - pathname of the directory to be listed.
Returns:
list of names of files in the directory.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
getFileNames(), getFileNames(boolean), getFileNames(String,boolean), "RFC959-4:1:3:'NLST'"

getFileNames

public java.lang.String[] getFileNames(java.lang.String pathname,
                                       boolean passive)
                                throws java.io.IOException,
                                       FTPException
Returns a directory listing for the path provided as parameter. An empty String argument implies the current directory. Value of passive will override the one returned by usePassiveDataTransfer().

Parameters:
pathname - pathname of the directory to be listed.
passive - give true to use passive data transfer.
Returns:
list of names of files in the directory.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0.2
See Also:
getFileNames(), getFileNames(String), getFileNames(boolean), "RFC959-4:1:3:'NLST'", "RFC959-4:1:2:'PASV'"

getFileDescriptors

public RemoteFile[] getFileDescriptors()
                                throws java.io.IOException,
                                       FTPException
Returns the complete description of the files in the current working directory.

Returns:
array of file descriptors.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
getFileDescriptors(String), getFileDescriptors(boolean), getFileDescriptors(String,boolean), "RFC959-4:1:3:'LIST'"

getFileDescriptors

public RemoteFile[] getFileDescriptors(boolean passive)
                                throws java.io.IOException,
                                       FTPException
Returns the complete description of the files in the current working directory. Value of passive will override the one returned by usePassiveDataTransfer().

Parameters:
passive - give true to use passive data transfer.
Returns:
array of file descriptors.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
getFileDescriptors(), getFileDescriptors(String), getFileDescriptors(String,boolean), "RFC959-4:1:3:'LIST'"

getFileDescriptors

public RemoteFile[] getFileDescriptors(java.lang.String pathname)
                                throws java.io.IOException,
                                       FTPException
Returns the complete description of the files in the directory specified by the path argument. An empty String argument implies the current directory.

Parameters:
pathname - pathname of the directory to be listed.
Returns:
array of file descriptors.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
getFileDescriptors(), getFileDescriptors(boolean), getFileDescriptors(String,boolean), "RFC959-4:1:3:'LIST'"

getFileDescriptors

public RemoteFile[] getFileDescriptors(java.lang.String pathname,
                                       boolean passive)
                                throws java.io.IOException,
                                       FTPException
Returns the complete description of the files in the directory specified by the path argument. An empty String argument implies the current directory. Value of passive will override the one returned by usePassiveDataTransfer(). Modified from contribution by Hector Mauricio Gonzalez (2005-03-31 Medellin Colombia).

Parameters:
pathname - pathname of the directory to be listed.
passive - give true to use passive data transfer.
Returns:
array of file descriptors.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
getFileDescriptors(), getFileDescriptors(String), getFileDescriptors(boolean), "RFC959-4:1:3:'LIST'"

getServerSystemName

public java.lang.String getServerSystemName()
                                     throws java.io.IOException,
                                            FTPException
Returns the type of operating system at the server, one of the system names listed in the current version of the 'Assigned Numbers Document' (as of 31-jul-00 : RFC1700).

Returns:
name of server system name.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
"RFC959-4:1:3:'SYST'", "RFC1700"

getServerStatus

public java.lang.String[] getServerStatus()
                                   throws java.io.IOException,
                                          FTPException
Returns the status response from the server. This method may be called during a file transfer in which case the server will respond with the status of the operation progress, or it may be sent between file transfers.

Returns:
status of the server.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
"RFC959-4:1:3:'STAT'", getServerStatus(String)

getServerStatus

public java.lang.String[] getServerStatus(java.lang.String pathname)
                                   throws java.io.IOException,
                                          FTPException
Returns the status response from the server. This method may be called during a file transfer in which case the server will respond with the status of the operation progress, or it may be sent between file transfers. In the latter case, an argument may be passed. If the argument is a pathname, the command is analogous to the getFileDescriptors. Programmer using this package should track FTPResponse.COMMAND_NOT_IMPLEMENTED_code FTPExceptions that this method may throw, because (at least some versions of) Solaris' FTP server don't seem to know about the STAT command.

Returns:
status of the server.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
"RFC959-4:1:3:'STAT'", getServerStatus()

putFile

public void putFile(java.io.InputStream data,
                    java.lang.String pathname)
             throws java.io.IOException,
                    FTPException
This command causes the server-DTP to accept the data transferred and to store the data as a file at the server site. If the file specified in the pathname exists at the server site, then its contents shall be replaced by the data being transferred. A new file is created at the server site if the file specified in the pathname does not already exist.

Parameters:
data - Stream from where to read the data to be transferred.
pathname - name or pathname of server site file where to store data.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
putFile(InputStream,String,boolean), putUniqueFile(InputStream), appendToFile(InputStream,String), "RFC959-4:1:3:'STOR'"

putFile

public void putFile(java.io.InputStream data,
                    java.lang.String pathname,
                    boolean passive)
             throws java.io.IOException,
                    FTPException
This command causes the server-DTP to accept the data transferred and to store the data as a file at the server site. If the file specified in the pathname exists at the server site, then its contents shall be replaced by the data being transferred. A new file is created at the server site if the file specified in the pathname does not already exist. Value of passive will override the one returned by usePassiveDataTransfer().

Parameters:
data - Stream from where to read the data to be transferred.
pathname - name or pathname of server site file where to store data.
passive - give true to use passive data transfer.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0.2
See Also:
putFile(InputStream,String), putUniqueFile(InputStream), appendToFile(InputStream,String), "RFC959-4:1:3:'STOR'", "RFC959-4:1:2:'PASV'"

putUniqueFile

public java.lang.String putUniqueFile(java.io.InputStream data)
                               throws java.io.IOException,
                                      FTPException
This command behaves like putFile (InputStream, String) except that the resultant file is to be created in the current directory nder a name unique to that directory. Returns the name generated.

Parameters:
data - Stream from where to read the data to be transferred.
Returns:
FTP server generated unique file name.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
putUniqueFile(InputStream,boolean), putFile(InputStream,String), appendToFile(InputStream,String), "RFC959-4:1:3:'STOU'"

putUniqueFile

public java.lang.String putUniqueFile(java.io.InputStream data,
                                      boolean passive)
                               throws java.io.IOException,
                                      FTPException
This command behaves like putFile (InputStream, String) except that the resultant file is to be created in the current directory nder a name unique to that directory. Returns the name generated. Value of passive will override the one returned by usePassiveDataTransfer().

Parameters:
data - Stream from where to read the data to be transferred.
passive - give true to use passive data transfer.
Returns:
FTP server generated unique file name.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
putUniqueFile(InputStream), putFile(InputStream,String), appendToFile(InputStream,String), "RFC959-4:1:3:'STOU'", "RFC959-4:1:2:'PASV'"

appendToFile

public void appendToFile(java.io.InputStream data,
                         java.lang.String pathname)
                  throws java.io.IOException,
                         FTPException
This command causes the server-DTP to accept the data transferred and to store the data in a file at the server site. If the file specified in the pathname exists at the server site, then the data shall be appended to that file; otherwise the file specified in the pathname shall be created at the server site.

Parameters:
pathname - name or pathname of server site file where to store or append data.
data - Stream from where to read the data to be transferred.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
"RFC959-4:1:3:'APPE'"

appendToFile

public void appendToFile(java.io.InputStream data,
                         java.lang.String pathname,
                         boolean passive)
                  throws java.io.IOException,
                         FTPException
This command causes the server-DTP to accept the data transferred and to store the data in a file at the server site. If the file specified in the pathname exists at the server site, then the data shall be appended to that file; otherwise the file specified in the pathname shall be created at the server site. Value of passive will override the one returned by usePassiveDataTransfer().

Parameters:
pathname - name or pathname of server site file where to store or append data.
data - Stream from where to read the data to be transferred.
passive - give true to use passive data transfer.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
"RFC959-4:1:3:'APPE'", "RFC959-4:1:2:'PASV'"

allocateSpace

public void allocateSpace(int bytes)
                   throws java.io.IOException,
                          FTPException
This command may be required by some servers to reserve sufficient storage to accomodate the new file to be transferred. The argument shall be a decimal integer representing the number of bytes of storage to be reserved for the file.

Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
allocateSpace(int,int), "RFC959-4:1:3:'ALLO'"

allocateSpace

public void allocateSpace(int space,
                          int size)
                   throws java.io.IOException,
                          FTPException
This command works just as allocateSpace (int), except that it allows to set a second (optional) parameter that may be required for files sent with record or page structure : a maximum record or page size.

Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
allocateSpace(int), "RFC959-4:1:3:'ALLO'"

getFile

public void getFile(java.io.OutputStream destination,
                    java.lang.String pathname)
             throws java.io.IOException,
                    FTPException
This command causes the server-DTP to transfer a copy of the file, specified in the pathname, to this client. The status and contents of the file at the server site shall be unaffected.

Parameters:
destination - where the file contents should be written to.
pathname - name or pathname of file to transfer.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
getFile(OutputStream,String,boolean), getFileFrom(OutputStream,String,int), "RFC959-4:1:3:'RETR'"

getFile

public void getFile(java.io.OutputStream destination,
                    java.lang.String pathname,
                    boolean passive)
             throws java.io.IOException,
                    FTPException
This command causes the server-DTP to transfer a copy of the file, specified in the pathname, to this client. The status and contents of the file at the server site shall be unaffected. Destination is not closed at the end of the download. Value of passive will override the one returned by usePassiveDataTransfer().

Parameters:
destination - where the file contents should be written to.
pathname - name or pathname of file to transfer.
passive - give true to use passive data transfer.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0.2
See Also:
getFile(OutputStream,String), getFileFrom(OutputStream,String,int), "RFC959-4:1:3:'RETR'", "RFC959-4:1:2:'PASV'"

getFileFrom

public void getFileFrom(java.io.OutputStream destination,
                        java.lang.String pathname,
                        int position)
                 throws java.io.IOException,
                        FTPException
The position argument field represents the server marker at which file transfer is to be restarted. This command skips over the file to the specified data checkpoint. Destination is not closed at the end of the download.

Parameters:
destination - where the file contents should be written to.
pathname - name or pathname of file to transfer.
position - marker from which to resume data transfer.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
getFile(OutputStream,String), "RFC959-4:1:3:'REST'"

renameFile

public void renameFile(java.lang.String from,
                       java.lang.String to)
                throws java.io.IOException,
                       FTPException
This command causes a file to be renamed from its old pathname to its new pathname.

Parameters:
from - old pathname of file to rename.
to - new pathname of file to rename.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
deleteFile(String), "RFC959-4:1:3:'RNFR'", "RFC959-4:1:3:'RNTO'"

deleteFile

public void deleteFile(java.lang.String pathname)
                throws java.io.IOException,
                       FTPException
This command causes the file specified as the pathname parameter to be deleted at the server site. This doesn't provide any kind of extra level of protection, e.g., "Do you really wish to delete?" message.

Parameters:
pathname - name or pathname of file to delete.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
renameFile(String,String), "RFC959-4:1:3:'DELE'"

abortCommand

public void abortCommand()
                  throws java.io.IOException,
                         FTPException
This command tells the server to abort the previous FTP service command and any associated transfer of data. The abort command may require "special action" to force recognition by the server. No action is to be taken if the previous command has been completed (including data transfer).

Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
"RFC959-4:1:3:'ABOR'"

makeDirectory

public void makeDirectory(java.lang.String pathname)
                   throws java.io.IOException,
                          FTPException
This command causes the directory specified in the pathname to be created as a directory (if the pathname is absolute) or as a subdirectory of the current working directory (if the pathname is relative).

Parameters:
pathname - name of (sub)directory to create.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
removeDirectory(String), "RFC959-4:1:3:'MKD'"

removeDirectory

public void removeDirectory(java.lang.String pathname)
                     throws java.io.IOException,
                            FTPException
This command causes the directory specified in the pathname to be removed as a directory (if the pathname is absolute) or as a subdirectory of the current working directory (if the pathname is relative).

Parameters:
pathname - name of (sub)directory to remove.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
makeDirectory(String), "RFC959-4:1:3:'RMD'"

setWorkingDirectory

public void setWorkingDirectory(java.lang.String pathname)
                         throws java.io.IOException,
                                FTPException
This command allows the user to work with a different directory or dataset for file storage or retrieval without altering his login of accounting information. Transfer parameters are similarly unchanged. The pathname argument specifies a directory of other system dependent file group designator.

Parameters:
pathname - name of (sub)directory to move to.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
setWorkingDirectoryUp(), getWorkingDirectory(), "RFC959-4:1:1:'CWD'"

setWorkingDirectoryUp

public void setWorkingDirectoryUp()
                           throws java.io.IOException,
                                  FTPException
This command is a special case of setWorkingDirectory (String), and is included to simplify the implementation of programs for transferring directory trees between operating systems having different syntaxes for naming the parent directory.

Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
setWorkingDirectory(String), getWorkingDirectory(), "RFC959-4:1:1:'CDUP'"

getWorkingDirectory

public java.lang.String getWorkingDirectory()
                                     throws java.io.IOException,
                                            FTPException
This command causes the name of the current working directory to be returned.

Returns:
current working directory pathname.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
setWorkingDirectory(String), setWorkingDirectoryUp(), "RFC959-4:1:3:'PWD'"

doSite

public java.lang.String doSite(java.lang.String command)
                        throws java.io.IOException,
                               FTPException
This command is used by the server to provide services specific to his system that are essential to file transfer but not sufficiently universal to be included as commands in the protocol. FIXME : The nature of these services and the specification of their syntax can be stated in a response to HELP SITE.

Returns:
FIXME : how to do that ?
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
"RFC959-4:1:3:'SITE'"

checkConnection

public boolean checkConnection()
                        throws java.io.IOException,
                               FTPException
This command does not affect any parameters or previously entered commands. It specifies no action other than that the server send an OK response.

Returns:
true when connection works fine. Thanks.
Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
"RFC959-4:1:3:'NOOP'"

mountStructure

public void mountStructure(java.lang.String system)
                    throws java.io.IOException,
                           FTPException
This command allows the user to mount a different file system data structure without altering his login or accounting information. Transfer parameters are similarly unchanged. The system is a pathname specifying a directory or other system dependent file group designator.

Throws:
java.io.IOException - something goes wrong with the sockets, streams, ...
FTPException - FTP server is not available or refuses connections.
Since:
v1.0
See Also:
"RFC959-4:1:1:'SMNT'"

toByteArray

protected byte[] toByteArray(short value)
Utility routine that takes a short value and chops it into a 2 bytes array.

Parameters:
value - to be chopped.
Returns:
chopped value.
Since:
v1.0

toByteArray

protected byte[] toByteArray(int value)
Utility routine that takes an int value and chops it into a 4 bytes array.

Parameters:
value - to be chopped.
Returns:
chopped value.
Since:
v1.0

toInt

protected int toInt(byte[] value)
Utility routine that takes a byte array value and links it into an int value. Most significant byte at position 0. Of course, value should not have more than 4 elements, or you'll notice an overflow.

Parameters:
value - to be linked.
Returns:
value[0]value[1]value[2]value[3]
Since:
v1.0

toUnsignedShort

protected short toUnsignedShort(byte value)
Utility routine that takes a byte value and transcripts it into a short value. The problem is that bytes greater than 127 are casted as negative shorts by the system.

Parameters:
value - to be transcripted.
Returns:
short value.
Since:
v1.0

notValidResponse

protected java.lang.String notValidResponse(int code,
                                            java.lang.String cmd)
Utility routine that composes the message used for FTPExceptions.

Parameters:
cmd - FTP command name that triggered the FTPException.
Returns:
standard exception message.
Since:
v1.0

closeServer

public void closeServer()
Deprecated. use FTPClient.close () instead. THIS METHOD WILL NOT BE CONTINUED.

Since:
kept for sun.net.ftp.FtpClient backcompatibility.
See Also:
sun.net.ftp.FtpClient#closeServer(), close()

openServer

public void openServer(java.lang.String server)
Deprecated. use FTPClient.open (String) instead. THIS METHOD WILL NOT BE CONTINUED.

Since:
kept for sun.net.ftp.FtpClient backcompatibility.
See Also:
sun.net.ftp.FtpClient#openServer(String), open(String)

openServer

public void openServer(java.lang.String server,
                       int port)
Deprecated. use FTPClient.open (String, int) instead. THIS METHOD WILL NOT BE CONTINUED.

Since:
kept for sun.net.ftp.FtpClient backcompatibility.
See Also:
sun.net.ftp.FtpClient#openServer(String,int), open(String,int)

get

public sun.net.TelnetInputStream get(java.lang.String pathname)
Deprecated. use FTPClient.getFile (String) instead. THIS METHOD WILL NOT BE CONTINUED.

Since:
kept for sun.net.ftp.FtpClient backcompatibility.
See Also:
getFile(OutputStream,String)

put

public sun.net.TelnetOutputStream put(java.lang.String pathname)
Deprecated. use FTPClient.putFile (InputStream, String) instead. THIS METHOD WILL NOT BE CONTINUED.

Since:
kept for sun.net.ftp.FtpClient backcompatibility.
See Also:
putFile(InputStream,String)

cd

public void cd(java.lang.String pathname)
Deprecated. use FTPClient.setWorkingDirectory (String) instead. THIS METHOD WILL NOT BE CONTINUED.

Since:
kept for sun.net.ftp.FtpClient backcompatibility.
See Also:
setWorkingDirectory(String)

binary

public void binary()
Deprecated. use FTPClient.setDataType (FTPConstants.IMAGE_DATA_TYPE) instead. THIS METHOD WILL NOT BE CONTINUED.

Since:
kept for sun.net.ftp.FtpClient backcompatibility.
See Also:
setDataType(int)

ascii

public void ascii()
Deprecated. use FTPClient.setDataType (FTPConstants.ASCII_DATA_TYPE) instead. THIS METHOD WILL NOT BE CONTINUED.

Since:
kept for sun.net.ftp.FtpClient backcompatibility.
See Also:
setDataType(int)


Copyright © 2009. All Rights Reserved.