|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.finj.FTPClient
public class FTPClient
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
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 FTPResponse s. |
|
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 FTPException s. |
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 byte s array. |
protected byte[] |
toByteArray(short value)
Utility routine that takes a short value and chops it
into a 2 byte s 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 |
---|
public FTPClient()
public FTPClient(java.util.Locale locale)
Locale
for internationalization
of FTPResponse
s. 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 !
locale
- used for internationalization of FTPResponse
messages.public FTPClient(java.lang.String server) throws java.io.IOException, FTPException
server
through the FTPConstants.DEFAULT_FTP_PORT
.
server
- DNS name or IP number of the FTP server to connect to.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available
or refuses connections.public FTPClient(java.lang.String server, java.util.Locale locale) throws java.io.IOException, FTPException
server
through the FTPConstants.DEFAULT_FTP_PORT
.
server
- DNS name or IP number of the FTP server to connect to.locale
- used for internationalization of FTPResponse
messages.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available
or refuses connections.public FTPClient(java.lang.String server, int port) throws java.io.IOException, FTPException
server
througn the provided port
.
server
- DNS name or IP number of the FTP server to connect to.port
- TCP port number to use for the control connection.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available
or refuses connections.public FTPClient(java.lang.String server, int port, java.util.Locale locale) throws java.io.IOException, FTPException
server
througn the provided port
.
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.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available
or refuses connections.public FTPClient(java.lang.String server, java.lang.String user, char[] pass) throws java.io.IOException, FTPException
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.
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.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available,
refuses connections or login information.public FTPClient(java.lang.String server, java.lang.String user, char[] pass, java.util.Locale locale) throws java.io.IOException, FTPException
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.
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.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available,
refuses connections or login information.public FTPClient(java.lang.String server, int port, java.lang.String user, char[] pass) throws java.io.IOException, FTPException
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.
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.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available,
refuses connections or login information.public FTPClient(java.lang.String server, int port, java.lang.String user, char[] pass, java.util.Locale locale) throws java.io.IOException, FTPException
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.
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.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available,
refuses connections or login information.Method Detail |
---|
public boolean isVerbose()
true
if verbose mode is on, false
if off.isVerbose(boolean)
public void isVerbose(boolean isIt)
isIt
- should verbose mode be activated?isVerbose()
public void setObserver(FTPClientObserver observer)
FTPClientObserver
is allowed per
FTPClient
observer
- new observer for this instance.hasObserver()
,
getObserver()
,
removeObserver()
public boolean hasObserver()
true
if this
is being
observed.setObserver(FTPClientObserver)
,
getObserver()
,
removeObserver()
public FTPClientObserver getObserver()
FTPClientObserver
is allowed per
FTPClient
setObserver(FTPClientObserver)
,
hasObserver()
,
removeObserver()
public void removeObserver()
FTPClientObserver
is allowed per
FTPClient
setObserver(FTPClientObserver)
,
hasObserver()
,
getObserver()
protected void broadcastResponse(FTPResponse response)
response
- response to command received from serverprotected void broadcastCommand(java.lang.String command)
command
- string sent to serverprotected void dataReceived(int bytes)
bytes
- amount of data received from serverdataSent(int)
protected void dataSent(int bytes)
bytes
- amount of data sent to serverdataReceived(int)
protected FTPResponse processCommand(FTPCommand command) throws java.io.IOException, FTPException
command
- FTP command to execute
FTPException
- something goes wrong with FTP codes
java.io.IOException
- something goes wrong with
the sockets, streams, ...protected FTPResponse processPostCommand(FTPCommand command) throws java.io.IOException, FTPException
command
- FTP command to execute
FTPException
- something goes wrong with FTP codes
java.io.IOException
- something goes wrong with
the sockets, streams, ...protected void sendFTPCommand(java.lang.String command) throws java.io.IOException
command
- FTP command to execute
java.io.IOException
- something goes wrong with
the sockets, streams, ...protected FTPResponse readFTPResponse() throws java.io.IOException
FTPResponse
representation of server's response.
java.io.IOException
- something goes wrong with
the sockets, streams, ...protected void writeLineToControlConnection(java.lang.String line) throws java.io.IOException
sendFTPCommand(String)
.
java.io.IOException
- something goes wrong with
the sockets, streams, ...sendFTPCommand(String)
protected java.lang.String readLineFromControlConnection() throws java.io.IOException
readFTPResponse
.
FTPResponse
representation of server's response.
java.io.IOException
- something goes wrong with
the sockets, streams, ...readFTPResponse()
public void open(java.lang.String server) throws java.io.IOException, FTPException, java.net.UnknownHostException
server
through the
FTPConstants.DEFAULT_FTP_PORT
.
server
- DNS name or IP number of the FTP server to connect to.
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.open(String,int)
public void open(java.lang.String server, int port) throws java.io.IOException, FTPException, java.net.UnknownHostException
server
through the
provided port
.
server
- DNS name or IP number of the FTP server to connect to.port
- TCP port number to use for the control connection.
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.open(String)
public boolean isConnected()
true
if a control connection
is currently opened between this client and
a FTP server, false
else.
protected void isConnected(boolean isIt)
isIt
- value to answer to the
isConnected ()
method calls.isConnected()
public void login(java.lang.String user, char[] pass) throws java.io.IOException, FTPException
connect
ing to it.
It is recommended that the character array be cleared after use by setting each character to zero.
user
- User name indentifier to use to log in.pass
- Password to use to log in.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available,
refuses connections or login information.public void setAccount(java.lang.String account) throws java.io.IOException, FTPException
account
- Account data used to identify user.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available,
refuses connections or account information.public void logout() throws java.io.IOException, FTPException
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.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available,
refuses connections or account information.close()
,
"RFC959-4:1:1:'REIN'"public void setDataPort(short port) throws java.io.IOException, FTPException
port
- 16-bits TCP port number to use for the data connection.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.setDataPort(int,short)
,
setDataPort(byte,byte,byte,byte,byte,byte)
,
"RFC959-4:1:2:'PORT'"public void setDataPort(int host, short port) throws java.io.IOException, FTPException
host
- 32-bits IP host address to use for the data connection.port
- 16-bits TCP port number to use for the data connection.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.setDataPort(short)
,
setDataPort(byte,byte,byte,byte,byte,byte)
,
"RFC959-4:1:2:'PORT'"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
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.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.setDataPort(short)
,
setDataPort(int,short)
,
"RFC959-4:1:2:'PORT'"public int getDataType()
FTPConstants.ASCII_DATA_TYPE
(default value),
FTPConstants.EBCDIC_DATA_TYPE
,
FTPConstants.IMAGE_DATA_TYPE
,
FTPConstants.LOCAL_DATA_TYPE
.
setDataType(int)
,
setDataType(int,int)
public void setDataType(int type) throws java.io.IOException, FTPException, java.lang.IllegalArgumentException
type
- one of
FTPConstants.ASCII_DATA_TYPE
(default value),
FTPConstants.EBCDIC_DATA_TYPE
,
FTPConstants.IMAGE_DATA_TYPE
,
FTPConstants.LOCAL_DATA_TYPE
.
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.setDataType(int,int)
,
getDataType()
,
"RFC959-3:1:1:Data types",
"RFC959-4:1:2:'TYPE'"public void setDataType(int type, int bytes) throws java.io.IOException, FTPException, java.lang.IllegalArgumentException
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".
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".
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.setDataType(int)
,
getDataType()
,
"RFC959-3:1:1:Data types",
"RFC959-4:1:2:'TYPE'"public int getDataStructure()
FTPConstants.FILE_DATA_STRUCTURE
(default value),
FTPConstants.RECORD_DATA_STRUCTURE
,
FTPConstants.PAGE_DATA_STRUCTURE
.
setDataStructure(int)
public void setDataStructure(int structure) throws java.io.IOException, FTPException, java.lang.IllegalArgumentException
FILE
and RECORD
structures are accepted for "text" files.
structure
- one of
FTPConstants.FILE_DATA_STRUCTURE
(default value),
FTPConstants.RECORD_DATA_STRUCTURE
,
FTPConstants.PAGE_DATA_STRUCTURE
.
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.getDataStructure()
,
"RFC959-3:1:2:Data structures",
"RFC959-4:1:2:'STRU'"public int getDataTransferMode()
FTPConstants.STREAM_DATA_TRANSMISSION_MODE
(default value),
FTPConstants.BLOCK_DATA_TRANSMISSION_MODE
,
FTPConstants.COMPRESSED_DATA_TRANSMISSION_MODE
.
setDataTransferMode(int)
public void setDataTransferMode(int mode) throws java.io.IOException, FTPException, java.lang.IllegalArgumentException
mode
- one of
FTPConstants.STREAM_DATA_TRANSMISSION_MODE
(default value),
FTPConstants.BLOCK_DATA_TRANSMISSION_MODE
,
FTPConstants.COMPRESSED_DATA_TRANSMISSION_MODE
.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.
java.lang.IllegalArgumentException
getDataTransferMode()
,
"RFC959-3:4:Transmission modes",
"RFC959-4:1:2:'MODE'"public void usePassiveDataTransfer(boolean isIt)
isIt
- change passive status to this value.public boolean usePassiveDataTransfer()
true
if data transfers are done
in passive mode.
true
when data connections to server are
done in passive mode.public void close() throws java.io.IOException, FTPException
logout
followed by the
login
methods should be called instead.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.logout()
,
"RFC959-4:1:1:'QUIT'"public java.lang.String[] getFileNames() throws java.io.IOException, FTPException
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.getFileNames(String)
,
getFileNames(boolean)
,
getFileNames(String,boolean)
,
"RFC959-4:1:3:'NLST'"public java.lang.String[] getFileNames(boolean passive) throws java.io.IOException, FTPException
passive
will override the one returned by
usePassiveDataTransfer()
.
passive
- give true
to use passive data transfer.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.getFileNames()
,
getFileNames(String)
,
getFileNames(String,boolean)
,
"RFC959-4:1:3:'NLST'",
"RFC959-4:1:2:'PASV'"public java.lang.String[] getFileNames(java.lang.String pathname) throws java.io.IOException, FTPException
String
argument implies the current directory.
pathname
- pathname of the directory to be listed.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.getFileNames()
,
getFileNames(boolean)
,
getFileNames(String,boolean)
,
"RFC959-4:1:3:'NLST'"public java.lang.String[] getFileNames(java.lang.String pathname, boolean passive) throws java.io.IOException, FTPException
String
argument implies the current directory.
Value of passive
will override the one returned by
usePassiveDataTransfer()
.
pathname
- pathname of the directory to be listed.passive
- give true
to use passive data transfer.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.getFileNames()
,
getFileNames(String)
,
getFileNames(boolean)
,
"RFC959-4:1:3:'NLST'",
"RFC959-4:1:2:'PASV'"public RemoteFile[] getFileDescriptors() throws java.io.IOException, FTPException
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.getFileDescriptors(String)
,
getFileDescriptors(boolean)
,
getFileDescriptors(String,boolean)
,
"RFC959-4:1:3:'LIST'"public RemoteFile[] getFileDescriptors(boolean passive) throws java.io.IOException, FTPException
passive
will override the one returned by
usePassiveDataTransfer()
.
passive
- give true
to use passive data transfer.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.getFileDescriptors()
,
getFileDescriptors(String)
,
getFileDescriptors(String,boolean)
,
"RFC959-4:1:3:'LIST'"public RemoteFile[] getFileDescriptors(java.lang.String pathname) throws java.io.IOException, FTPException
path
argument.
An empty String
argument implies the current directory.
pathname
- pathname of the directory to be listed.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.getFileDescriptors()
,
getFileDescriptors(boolean)
,
getFileDescriptors(String,boolean)
,
"RFC959-4:1:3:'LIST'"public RemoteFile[] getFileDescriptors(java.lang.String pathname, boolean passive) throws java.io.IOException, FTPException
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).
pathname
- pathname of the directory to be listed.passive
- give true
to use passive data transfer.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.getFileDescriptors()
,
getFileDescriptors(String)
,
getFileDescriptors(boolean)
,
"RFC959-4:1:3:'LIST'"public java.lang.String getServerSystemName() throws java.io.IOException, FTPException
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.public java.lang.String[] getServerStatus() throws java.io.IOException, FTPException
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.getServerStatus(String)
public java.lang.String[] getServerStatus(java.lang.String pathname) throws java.io.IOException, FTPException
getFileDescriptors
.
Programmer using this package should track
FTPResponse.COMMAND_NOT_IMPLEMENTED_code FTPException
s
that this method may throw, because (at least some versions of)
Solaris' FTP server don't seem to know about the STAT
command.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.getServerStatus()
public void putFile(java.io.InputStream data, java.lang.String pathname) throws java.io.IOException, FTPException
data
- Stream
from where to read the data to be
transferred.pathname
- name or pathname of server site file where to store data.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.putFile(InputStream,String,boolean)
,
putUniqueFile(InputStream)
,
appendToFile(InputStream,String)
,
"RFC959-4:1:3:'STOR'"public void putFile(java.io.InputStream data, java.lang.String pathname, boolean passive) throws java.io.IOException, FTPException
passive
will override the one returned by
usePassiveDataTransfer()
.
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.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.putFile(InputStream,String)
,
putUniqueFile(InputStream)
,
appendToFile(InputStream,String)
,
"RFC959-4:1:3:'STOR'",
"RFC959-4:1:2:'PASV'"public java.lang.String putUniqueFile(java.io.InputStream data) throws java.io.IOException, FTPException
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.
data
- Stream
from where to read the data to be
transferred.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.putUniqueFile(InputStream,boolean)
,
putFile(InputStream,String)
,
appendToFile(InputStream,String)
,
"RFC959-4:1:3:'STOU'"public java.lang.String putUniqueFile(java.io.InputStream data, boolean passive) throws java.io.IOException, FTPException
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()
.
data
- Stream
from where to read the data to be
transferred.passive
- give true
to use passive data transfer.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.putUniqueFile(InputStream)
,
putFile(InputStream,String)
,
appendToFile(InputStream,String)
,
"RFC959-4:1:3:'STOU'",
"RFC959-4:1:2:'PASV'"public void appendToFile(java.io.InputStream data, java.lang.String pathname) throws java.io.IOException, FTPException
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.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.public void appendToFile(java.io.InputStream data, java.lang.String pathname, boolean passive) throws java.io.IOException, FTPException
passive
will override the one returned by
usePassiveDataTransfer()
.
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.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.public void allocateSpace(int bytes) throws java.io.IOException, FTPException
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.allocateSpace(int,int)
,
"RFC959-4:1:3:'ALLO'"public void allocateSpace(int space, int size) throws java.io.IOException, FTPException
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.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.allocateSpace(int)
,
"RFC959-4:1:3:'ALLO'"public void getFile(java.io.OutputStream destination, java.lang.String pathname) throws java.io.IOException, FTPException
destination
- where the file contents should be written to.pathname
- name or pathname of file to transfer.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.getFile(OutputStream,String,boolean)
,
getFileFrom(OutputStream,String,int)
,
"RFC959-4:1:3:'RETR'"public void getFile(java.io.OutputStream destination, java.lang.String pathname, boolean passive) throws java.io.IOException, FTPException
passive
will override the one returned by
usePassiveDataTransfer()
.
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.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.getFile(OutputStream,String)
,
getFileFrom(OutputStream,String,int)
,
"RFC959-4:1:3:'RETR'",
"RFC959-4:1:2:'PASV'"public void getFileFrom(java.io.OutputStream destination, java.lang.String pathname, int position) throws java.io.IOException, FTPException
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.
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.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.getFile(OutputStream,String)
,
"RFC959-4:1:3:'REST'"public void renameFile(java.lang.String from, java.lang.String to) throws java.io.IOException, FTPException
from
its
old pathname to
its new pathname.
from
- old pathname of file to rename.to
- new pathname of file to rename.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.deleteFile(String)
,
"RFC959-4:1:3:'RNFR'",
"RFC959-4:1:3:'RNTO'"public void deleteFile(java.lang.String pathname) throws java.io.IOException, FTPException
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.
pathname
- name or pathname of file to delete.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.renameFile(String,String)
,
"RFC959-4:1:3:'DELE'"public void abortCommand() throws java.io.IOException, FTPException
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.public void makeDirectory(java.lang.String pathname) throws java.io.IOException, FTPException
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).
pathname
- name of (sub)directory to create.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.removeDirectory(String)
,
"RFC959-4:1:3:'MKD'"public void removeDirectory(java.lang.String pathname) throws java.io.IOException, FTPException
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).
pathname
- name of (sub)directory to remove.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.makeDirectory(String)
,
"RFC959-4:1:3:'RMD'"public void setWorkingDirectory(java.lang.String pathname) throws java.io.IOException, FTPException
pathname
argument specifies a directory of other
system dependent file group designator.
pathname
- name of (sub)directory to move to.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.setWorkingDirectoryUp()
,
getWorkingDirectory()
,
"RFC959-4:1:1:'CWD'"public void setWorkingDirectoryUp() throws java.io.IOException, FTPException
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.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.setWorkingDirectory(String)
,
getWorkingDirectory()
,
"RFC959-4:1:1:'CDUP'"public java.lang.String getWorkingDirectory() throws java.io.IOException, FTPException
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.setWorkingDirectory(String)
,
setWorkingDirectoryUp()
,
"RFC959-4:1:3:'PWD'"public java.lang.String doSite(java.lang.String command) throws java.io.IOException, FTPException
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.public boolean checkConnection() throws java.io.IOException, FTPException
true
when connection works fine. Thanks.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.public void mountStructure(java.lang.String system) throws java.io.IOException, FTPException
system
is a pathname specifying a directory or other system dependent file
group designator.
java.io.IOException
- something goes wrong with
the sockets, streams, ...
FTPException
- FTP server is not available or
refuses connections.protected byte[] toByteArray(short value)
short
value and chops it
into a 2 byte
s array.
value
- to be chopped.
protected byte[] toByteArray(int value)
int
value and chops it
into a 4 byte
s array.
value
- to be chopped.
protected int toInt(byte[] value)
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.
value
- to be linked.
value[0]value[1]value[2]value[3]
protected short toUnsignedShort(byte value)
byte
value and
transcripts it into a short
value. The problem
is that byte
s greater than 127 are casted as
negative short
s by the system.
value
- to be transcripted.
protected java.lang.String notValidResponse(int code, java.lang.String cmd)
FTPException
s.
cmd
- FTP command name that triggered the FTPException.
public void closeServer()
FTPClient.close ()
instead.
THIS METHOD WILL NOT BE CONTINUED.
sun.net.ftp.FtpClient
backcompatibility.sun.net.ftp.FtpClient#closeServer()
,
close()
public void openServer(java.lang.String server)
FTPClient.open (String)
instead.
THIS METHOD WILL NOT BE CONTINUED.
sun.net.ftp.FtpClient
backcompatibility.sun.net.ftp.FtpClient#openServer(String)
,
open(String)
public void openServer(java.lang.String server, int port)
FTPClient.open (String, int)
instead.
THIS METHOD WILL NOT BE CONTINUED.
sun.net.ftp.FtpClient
backcompatibility.sun.net.ftp.FtpClient#openServer(String,int)
,
open(String,int)
public sun.net.TelnetInputStream get(java.lang.String pathname)
FTPClient.getFile (String)
instead.
THIS METHOD WILL NOT BE CONTINUED.
sun.net.ftp.FtpClient
backcompatibility.getFile(OutputStream,String)
public sun.net.TelnetOutputStream put(java.lang.String pathname)
FTPClient.putFile (InputStream, String)
instead.
THIS METHOD WILL NOT BE CONTINUED.
sun.net.ftp.FtpClient
backcompatibility.putFile(InputStream,String)
public void cd(java.lang.String pathname)
FTPClient.setWorkingDirectory (String)
instead.
THIS METHOD WILL NOT BE CONTINUED.
sun.net.ftp.FtpClient
backcompatibility.setWorkingDirectory(String)
public void binary()
FTPClient.setDataType (FTPConstants.IMAGE_DATA_TYPE)
instead.
THIS METHOD WILL NOT BE CONTINUED.
sun.net.ftp.FtpClient
backcompatibility.setDataType(int)
public void ascii()
FTPClient.setDataType (FTPConstants.ASCII_DATA_TYPE)
instead.
THIS METHOD WILL NOT BE CONTINUED.
sun.net.ftp.FtpClient
backcompatibility.setDataType(int)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |