|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface FTPSimpleClientI
Simple FTP client interface. Allows clients to establish FTP connections, send and receive files, get remote directory listings, etc.
Field Summary | |
---|---|
static java.lang.String |
REV
Revision information. |
Method Summary | |
---|---|
void |
appendFile(java.io.File src,
java.lang.String dst)
Append (send) a file from the local system to a file on the remote FTP system. |
void |
appendFile(java.io.InputStream in,
java.lang.String dst)
Append (send) a file from the local system to a file on the remote FTP system. |
void |
connect()
Connect to the remote FTP system. |
void |
createDirectory(java.lang.String dir)
Create a directory on the remote FTP system. |
void |
disconnect()
Disconnect from the remote FTP system. |
int |
getCommandPort()
Retrieve the FTP command port number. |
int |
getDataPort()
Retrieve the FTP data port number. |
java.util.ArrayList<java.lang.String> |
getDirectoryNames(java.lang.String path,
java.io.FilenameFilter filt,
int max)
Get (receive) a list of filenames in a directory on the remote FTP system. |
java.util.ArrayList<java.lang.String> |
getDirectoryNames(java.lang.String path,
int max)
Get (receive) a list of filenames in a directory on the remote FTP system. |
void |
getFile(java.lang.String src,
java.io.File dst)
Get (receive) a file from the remote FTP system to the local system. |
void |
getFile(java.lang.String src,
java.io.OutputStream out)
Get (receive) a file from the remote FTP system to the local system. |
java.lang.String |
getHost()
Retrieve the remote FTP host name. |
java.lang.String |
getLocalDir()
Retrieve the working directory of the local system. |
java.lang.String |
getPassword()
Retrieve the user password. |
java.lang.String |
getRemoteDir()
Retrieve the working directory of the remote FTP system. |
int |
getTimeOut()
Retrieve the FTP I/O time-out. |
java.lang.String |
getUserID()
Retrieve the user-ID. |
boolean |
isConnected()
Determine if this client is connected to the remote FTP system. |
boolean |
isLoggedIn()
Determine if this client is logged to the remote FTP system. |
void |
login()
Log on to the remote FTP system. |
void |
putFile(java.io.File src,
java.lang.String dst)
Put (send) a file from the local system to the remote FTP system. |
void |
putFile(java.io.InputStream in,
java.lang.String dst)
Put (send) a file from the local system to the remote FTP system. |
void |
removeDirectory(java.lang.String dir)
Remove a directory on the remote FTP system. |
void |
removeFile(java.lang.String file)
Remove a file on the remote FTP system. |
void |
rename(java.lang.String from,
java.lang.String to)
Rename a file or directory on the remote FTP system. |
int |
setBufferSize(int len)
Set the size of the FTP data transfer buffer. |
void |
setCommandPort(int port)
Set the remote FTP command port number. |
void |
setDataPort(int port)
Set the remote FTP data port number. |
void |
setHost(java.lang.String host)
Set the remote FTP host (system) name. |
void |
setLocalDir(java.lang.String dir)
Set the working directory on the local system. |
boolean |
setPassive(boolean flag)
Set this FTP client to operate (or not) in passive data transfer mode. |
void |
setPassword(java.lang.String pwd)
Set the user password. |
java.lang.String |
setRemoteDir(java.lang.String dir)
Set the working directory on the remote FTP system. |
java.lang.String |
setRemoteDirUp()
Set the working directory on the remote FTP system to the parent directory of the current working directory. |
boolean |
setTextMode(boolean flag)
Set the transfer mode to text (ASCII) or binary. |
void |
setTimeOut(int secs)
Set the remote FTP I/O time-out. |
void |
setUserID(java.lang.String id)
Set the user name (user-ID). |
Field Detail |
---|
static final java.lang.String REV
Method Detail |
---|
java.lang.String getHost()
setHost()
void setHost(java.lang.String host)
host
- FTP system host name or IP address.getHost()
int getCommandPort()
setCommandPort()
,
getDataPort()
void setCommandPort(int port)
port
- FTP command port number. (The default FTP port is 21.)getCommandPort()
,
setDataPort()
int getDataPort()
setDataPort()
,
getCommandPort()
void setDataPort(int port)
port
- FTP data port number. Setting this to zero or a negative number causes
the data ports to be chosen (randomly) by the local system when operating
in non-passive mode. (The default FTP port is 0.)getDataPort()
,
setCommandPort()
int getTimeOut()
setTimeOut()
,
getCommandPort()
,
getDataPort()
void setTimeOut(int secs)
secs
- FTP I/O time-out, in seconds.getTimeOut()
,
setCommandPort()
,
setDataPort()
int setBufferSize(int len)
len
- New buffer size.
Values between 1K (1,024) and 16K (16,384) are probably optimal for most
applications.
Classes that implement this interface may choose to ignore this setting.
java.lang.IllegalArgumentException
- (unchecked)
Thrown if len is less than 1.appendFile()
,
getFile()
,
putFile()
java.lang.String getUserID()
setUserID()
void setUserID(java.lang.String id)
id
- User-ID.getUserID()
java.lang.String getPassword()
setPassword()
void setPassword(java.lang.String pwd)
pwd
- User password.getPassword()
boolean setPassive(boolean flag)
flag
- If true, the data transfer mode is set to passive, otherwise it is set to
non-passive (active listen) mode.
void connect() throws java.io.IOException
java.io.IOException
- Thrown if unable to connect to the remote FTP system.disconnect()
void disconnect()
IOException
.
connect()
boolean isConnected()
connect()
,
disconnect()
void login() throws java.io.IOException
java.io.IOException
- Thrown if an error occurs.connect()
,
setUserID()
,
setPassword()
boolean isLoggedIn()
login()
boolean setTextMode(boolean flag)
flag
- If true, the transfer mode is set to "ASCII" (text), otherwise it is set
to "binary".
java.lang.String setRemoteDir(java.lang.String dir) throws java.io.IOException
dir
- Remote directory name.
java.io.IOException
- Thrown if an error occurs.getRemoteDir()
,
setLocalDir()
java.lang.String setRemoteDirUp() throws java.io.IOException
java.io.IOException
- Thrown if an error occurs.getRemoteDir()
,
setRemoteDir()
,
setLocalDir()
java.lang.String getRemoteDir() throws java.io.IOException
java.io.IOException
- Thrown if an error occurs.setRemoteDir()
,
getLocalDir()
void setLocalDir(java.lang.String dir) throws java.io.IOException
dir
- Local directory name.
java.io.IOException
- Thrown if an error occurs.getLocalDir()
,
setRemoteDir()
java.lang.String getLocalDir() throws java.io.IOException
java.io.IOException
- Thrown if an error occurs.setLocalDir()
,
getRemoteDir()
void getFile(java.lang.String src, java.io.File dst) throws java.io.IOException
src
- Remote source filename. If this does not contain a directory prefix, the
current remote working directory is assumed.dst
- Local source filename. If this does not contain a directory prefix, the
current local working directory is assumed. This may be null, in which
case the base filename of src (without the directory prefix) is
used.
java.io.IOException
- Thrown if the file could not be transmitted or if any other error occurs.getFile()
,
putFile()
,
appendFile()
void getFile(java.lang.String src, java.io.OutputStream out) throws java.io.IOException
src
- Remote source filename. If this does not contain a directory prefix, the
current remote working directory is assumed.out
- Output stream to write the contents of the file retrieved from the remote
FTP system to. Note that this stream is flushed but is not closed
after the contents have been transmitted.
java.io.IOException
- Thrown if the file could not be transmitted or if any other error occurs.getFile()
,
putFile()
,
appendFile()
void putFile(java.io.File src, java.lang.String dst) throws java.io.IOException
src
- Local source filename. If this does not contain a directory prefix, the
current local working directory is assumed.dst
- Remote target filename. If this does not contain a directory prefix, the
current remote working directory is assumed. This may be null, in which
case the base filename of src (without the directory prefix) is
used.
java.io.IOException
- Thrown if the file could not be transmitted or if any other error occurs.putFile()
,
appendFile()
,
getFile()
void putFile(java.io.InputStream in, java.lang.String dst) throws java.io.IOException
in
- Input stream containing the contents of the file to send to the remote FTP
system. Note that this stream is not closed after the contents
have been transmitted.dst
- Remote target filename. If this does not contain a directory prefix, the
current remote working directory is assumed. This may be null, in which
case the base filename of src (without the directory prefix) is
used.
java.io.IOException
- Thrown if the file could not be transmitted or if any other error occurs.putFile()
,
appendFile()
,
getFile()
void appendFile(java.io.File src, java.lang.String dst) throws java.io.IOException
src
- Local source filename. If this does not contain a directory prefix, the
current local working directory is assumed.dst
- Remote target filename. If this does not contain a directory prefix, the
current remote working directory is assumed. This may be null, in which
case the base filename of src (without the directory prefix) is
used.
java.io.IOException
- Thrown if the file could not be transmitted or if any other error occurs.appendFile()
,
putFile()
,
getFile()
void appendFile(java.io.InputStream in, java.lang.String dst) throws java.io.IOException
in
- Input stream containing the contents of the file to send to the remote FTP
system. Note that this stream is not closed after the contents
have been transmitted.dst
- Remote target filename. If this does not contain a directory prefix, the
current remote working directory is assumed. This may be null, in which
case the base filename of src (without the directory prefix) is
used.
java.io.IOException
- Thrown if the file could not be transmitted or if any other error occurs.appendFile()
,
putFile()
,
getFile()
java.util.ArrayList<java.lang.String> getDirectoryNames(java.lang.String path, int max) throws java.io.IOException
path
- The remote directory or filename to list. If this is empty
(""), the current remote working directory is assumed.max
- Maximum number of filenames to list. A value of zero (0) specifies that
there is no maximum.
java.io.IOException
- Thrown if an error occurs.java.util.ArrayList<java.lang.String> getDirectoryNames(java.lang.String path, java.io.FilenameFilter filt, int max) throws java.io.IOException
path
- The remote directory or filename to list. If this is empty
(""), the current remote working directory is assumed.filt
- Filer to apply to the filenames. Only filenames that are accepted by the
filter will appear in the returned vector. If this is null, no filtering
is applied to the filenames. This object's accept() method is
called for each filename in the directory, being passed a null directory
(first argument) and the found filename (second argument).max
- Maximum number of filenames to return. A value of zero (0) specifies that
there is no maximum.
java.io.IOException
- Thrown if an error occurs.void rename(java.lang.String from, java.lang.String to) throws java.io.IOException
from
- Old (existing) remote file or directory name to rename.to
- New name to rename the remote file or directory to.
java.io.IOException
- Thrown if an error occurs.void removeFile(java.lang.String file) throws java.io.IOException
file
- Name of the file to delete. If this specifies a relative filename, the
file is assumed to be located in the current remote working directory.
java.io.IOException
- Thrown if an error occurs.void createDirectory(java.lang.String dir) throws java.io.IOException
dir
- Name of the directory to create. If this specifies a relative directory
name, the directory is created in the current remote working directory.
java.io.IOException
- Thrown if an error occurs.void removeDirectory(java.lang.String dir) throws java.io.IOException
dir
- Name of the directory to delete. If this specifies a relative directory
name, the directory is assumed to be located in the current remote working
directory.
java.io.IOException
- Thrown if an error occurs.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |