| java.lang.Object com.enterprisedt.net.ftp.FTPClient
FTPClient | public class FTPClient (Code) | | Supports client-side FTP. Most common
FTP operations are present in this class.
author: Bruce Blackshaw version: $Revision: 1.1.1.1 $ |
Constructor Summary | |
public | FTPClient(String remoteHost) Constructor. | public | FTPClient(String remoteHost, int controlPort) Constructor. | public | FTPClient(InetAddress remoteAddr) Constructor. | public | FTPClient(InetAddress remoteAddr, int controlPort) Constructor. | public | FTPClient(String remoteHost, PrintWriter log, int timeout) Constructor. | public | FTPClient(String remoteHost, int controlPort, PrintWriter log, int timeout) Constructor. | public | FTPClient(InetAddress remoteAddr, PrintWriter log, int timeout) Constructor. | public | FTPClient(InetAddress remoteAddr, int controlPort, PrintWriter log, int timeout) Constructor. |
Method Summary | |
public void | chdir(String dir) | public void | debugResponses(boolean on) | public void | delete(String remoteFile) | public String[] | dir() List current directory's contents as an array of strings of
filenames. | public String[] | dir(String dirname) List a directory's contents as an array of strings of filenames. | public String[] | dir(String dirname, boolean full) List a directory's contents as an array of strings. | public void | get(String localPath, String remoteFile) Get data from the FTP server. | public void | get(OutputStream destStream, String remoteFile) Get data from the FTP server. | public byte[] | get(String remoteFile) Get data from the FTP server. | public FTPReply | getLastValidReply() | String | getRemoteHostName() | public FTPTransferType | getType() Get the current transfer type
the current type of the transfer,i.e. | public String | help(String command) | public static void | initSOCKS(String port, String host) Set up SOCKS v4/v5 proxy settings. | public static void | initSOCKSAuthentication(String username, String password) Set up SOCKS username and password for SOCKS username/password
authentication. | public String | list(String dirname) | public String | list(String dirname, boolean full) List a directory's contents as one string. | public void | login(String user, String password) Login into an account on the FTP server. | public void | mkdir(String dir) | public Date | modtime(String remoteFile) | public void | password(String password) Supplies the password for a previously supplied
username to log into the FTP server. | public void | put(String localPath, String remoteFile) Put a local file onto the FTP server. | public void | put(InputStream srcStream, String remoteFile) Put a stream of data onto the FTP server. | public void | put(String localPath, String remoteFile, boolean append) Put a local file onto the FTP server. | public void | put(InputStream srcStream, String remoteFile, boolean append) Put a stream of data onto the FTP server. | public void | put(byte[] bytes, String remoteFile) Put data onto the FTP server. | public void | put(byte[] bytes, String remoteFile, boolean append) Put data onto the FTP server. | public String | pwd() | public void | quit() | public void | quote(String command, String[] validCodes) Issue arbitrary ftp commands to the FTP server. | public void | rename(String from, String to) | public void | rmdir(String dir) | public void | setConnectMode(FTPConnectMode mode) | public void | setLogStream(PrintWriter log) | public void | setTimeout(int millis) Set the TCP timeout on the underlying socket.
If a timeout is set, then any operation which
takes longer than the timeout value will be
killed with a java.io.InterruptedException. | public void | setType(FTPTransferType type) | public boolean | site(String command) Run a site-specific command on the
server. | public String | system() | public void | user(String user) Supply the user name to log into an account
on the FTP server. |
FTPClient | public FTPClient(String remoteHost, int controlPort) throws IOException, FTPException(Code) | | Constructor. Creates the control
socket
Parameters: remoteHost - the remote hostname Parameters: controlPort - port for control stream |
FTPClient | public FTPClient(InetAddress remoteAddr, int controlPort) throws IOException, FTPException(Code) | | Constructor. Creates the control
socket. Allows setting of control port (normally
set by default to 21).
Parameters: remoteAddr - the address of theremote host Parameters: controlPort - port for control stream |
FTPClient | public FTPClient(String remoteHost, PrintWriter log, int timeout) throws IOException, FTPException(Code) | | Constructor. Creates the control
socket
Parameters: remoteHost - the remote hostname Parameters: millis - the length of the timeout, in milliseconds |
FTPClient | public FTPClient(String remoteHost, int controlPort, PrintWriter log, int timeout) throws IOException, FTPException(Code) | | Constructor. Creates the control
socket
Parameters: remoteHost - the remote hostname Parameters: controlPort - port for control stream Parameters: millis - the length of the timeout, in milliseconds |
FTPClient | public FTPClient(InetAddress remoteAddr, PrintWriter log, int timeout) throws IOException, FTPException(Code) | | Constructor. Creates the control
socket
Parameters: remoteAddr - the address of theremote host Parameters: millis - the length of the timeout, in milliseconds |
FTPClient | public FTPClient(InetAddress remoteAddr, int controlPort, PrintWriter log, int timeout) throws IOException, FTPException(Code) | | Constructor. Creates the control
socket. Allows setting of control port (normally
set by default to 21).
Parameters: remoteAddr - the address of theremote host Parameters: controlPort - port for control stream Parameters: millis - the length of the timeout, in milliseconds |
chdir | public void chdir(String dir) throws IOException, FTPException(Code) | | Change the remote working directory to
that supplied
Parameters: dir - name of remote directory tochange to |
debugResponses | public void debugResponses(boolean on)(Code) | | Switch debug of responses on or off
Parameters: on - true if you wish to have responses tothe log stream, false otherwise |
dir | public String[] dir() throws IOException, FTPException(Code) | | List current directory's contents as an array of strings of
filenames.
an array of current directory listing strings |
dir | public String[] dir(String dirname) throws IOException, FTPException(Code) | | List a directory's contents as an array of strings of filenames.
Parameters: dirname - name of directory(not a file mask) an array of directory listing strings |
dir | public String[] dir(String dirname, boolean full) throws IOException, FTPException(Code) | | List a directory's contents as an array of strings. A detailed
listing is available, otherwise just filenames are provided.
The detailed listing varies in details depending on OS and
FTP server. Note that a full listing can be used on a file
name to obtain information about a file
Parameters: dirname - name of directory (not a file mask) Parameters: full - true if detailed listing requiredfalse otherwise an array of directory listing strings |
get | public void get(String localPath, String remoteFile) throws IOException, FTPException(Code) | | Get data from the FTP server. Uses the currently
set transfer mode.
Parameters: localPath - local file to put data in Parameters: remoteFile - name of remote file incurrent directory |
get | public void get(OutputStream destStream, String remoteFile) throws IOException, FTPException(Code) | | Get data from the FTP server. Uses the currently
set transfer mode.
Parameters: destStream - data stream to write data to Parameters: remoteFile - name of remote file incurrent directory |
get | public byte[] get(String remoteFile) throws IOException, FTPException(Code) | | Get data from the FTP server. Transfers in
whatever mode we are in. Retrieve as a byte array. Note
that we may experience memory limitations as the
entire file must be held in memory at one time.
Parameters: remoteFile - name of remote file incurrent directory |
getLastValidReply | public FTPReply getLastValidReply()(Code) | | Gets the latest valid reply from the server
reply object encapsulating last valid server response |
getRemoteHostName | String getRemoteHostName()(Code) | | Get the name of the remote host
remote host name |
getType | public FTPTransferType getType()(Code) | | Get the current transfer type
the current type of the transfer,i.e. BINARY or ASCII |
help | public String help(String command) throws IOException, FTPException(Code) | | Get the help text for the specified command
Parameters: command - name of the command to get help on help text from the server for the supplied command |
initSOCKS | public static void initSOCKS(String port, String host)(Code) | | Set up SOCKS v4/v5 proxy settings. This can be used if there
is a SOCKS proxy server in place that must be connected thru.
Note that setting these properties directs all TCP
sockets in this JVM to the SOCKS proxy
Parameters: port - SOCKS proxy port Parameters: host - SOCKS proxy hostname |
initSOCKSAuthentication | public static void initSOCKSAuthentication(String username, String password)(Code) | | Set up SOCKS username and password for SOCKS username/password
authentication. Often, no authentication will be required
but the SOCKS server may be configured to request these.
Parameters: username - the SOCKS username Parameters: password - the SOCKS password |
list | public String list(String dirname, boolean full) throws IOException, FTPException(Code) | | List a directory's contents as one string. A detailed
listing is available, otherwise just filenames are provided.
The detailed listing varies in details depending on OS and
FTP server.
Parameters: dirname - the name of the directory(not a file mask) Parameters: full - true if detailed listing requiredfalse otherwise a string containing the line separateddirectory listingFTPClient.dir(String,boolean) |
login | public void login(String user, String password) throws IOException, FTPException(Code) | | Login into an account on the FTP server. This
call completes the entire login process
Parameters: user - user name Parameters: password - user's password |
modtime | public Date modtime(String remoteFile) throws IOException, FTPException(Code) | | Get modification time for a remote file
Parameters: remoteFile - name of remote file modification time of file as a date |
password | public void password(String password) throws IOException, FTPException(Code) | | Supplies the password for a previously supplied
username to log into the FTP server. Must be
preceeded by the user() method
Parameters: user - user name Parameters: password - user's password |
put | public void put(String localPath, String remoteFile) throws IOException, FTPException(Code) | | Put a local file onto the FTP server. It
is placed in the current directory.
Parameters: localPath - path of the local file Parameters: remoteFile - name of remote file incurrent directory |
put | public void put(InputStream srcStream, String remoteFile) throws IOException, FTPException(Code) | | Put a stream of data onto the FTP server. It
is placed in the current directory.
Parameters: srcStream - input stream of data to put Parameters: remoteFile - name of remote file incurrent directory |
put | public void put(String localPath, String remoteFile, boolean append) throws IOException, FTPException(Code) | | Put a local file onto the FTP server. It
is placed in the current directory. Allows appending
if current file exists
Parameters: localPath - path of the local file Parameters: remoteFile - name of remote file incurrent directory Parameters: append - true if appending, false otherwise |
put | public void put(InputStream srcStream, String remoteFile, boolean append) throws IOException, FTPException(Code) | | Put a stream of data onto the FTP server. It
is placed in the current directory. Allows appending
if current file exists
Parameters: srcStream - input stream of data to put Parameters: remoteFile - name of remote file incurrent directory Parameters: append - true if appending, false otherwise |
put | public void put(byte[] bytes, String remoteFile) throws IOException, FTPException(Code) | | Put data onto the FTP server. It
is placed in the current directory.
Parameters: data - array of bytes Parameters: remoteFile - name of remote file incurrent directory |
put | public void put(byte[] bytes, String remoteFile, boolean append) throws IOException, FTPException(Code) | | Put data onto the FTP server. It
is placed in the current directory. Allows
appending if current file exists
Parameters: data - array of bytes Parameters: remoteFile - name of remote file incurrent directory Parameters: append - true if appending, false otherwise |
quote | public void quote(String command, String[] validCodes) throws IOException, FTPException(Code) | | Issue arbitrary ftp commands to the FTP server.
Parameters: command - ftp command to be sent to server Parameters: validCodes - valid return codes for this command |
setConnectMode | public void setConnectMode(FTPConnectMode mode)(Code) | | Set the connect mode
Parameters: mode - ACTIVE or PASV mode |
setLogStream | public void setLogStream(PrintWriter log)(Code) | | Set the logging stream, replacing
stdout
Parameters: log - the new logging stream |
setTimeout | public void setTimeout(int millis) throws IOException(Code) | | Set the TCP timeout on the underlying socket.
If a timeout is set, then any operation which
takes longer than the timeout value will be
killed with a java.io.InterruptedException. We
set both the control and data connections
Parameters: millis - The length of the timeout, in milliseconds |
site | public boolean site(String command) throws IOException, FTPException(Code) | | Run a site-specific command on the
server. Support for commands is dependent
on the server
Parameters: command - the site command to run true if command ok, false ifcommand not implemented |
user | public void user(String user) throws IOException, FTPException(Code) | | Supply the user name to log into an account
on the FTP server. Must be followed by the
password() method - but we allow for
Parameters: user - user name Parameters: password - user's password |
|
|