| org.archive.net.ClientFTP
ClientFTP | public class ClientFTP extends FTPClient (Code) | | Client for FTP operations. This class is necessary only because the
ClientFTP._openDataConnection_(int,String) method is protected in
the superclass, and we need to call it directly to handle directory
listings. (The code that provides directory listings in the
superclass doesn't scale: It reads the entire directory into
an in-memory list).
Additionally, "strict" methods are provided for the other operations
we use. Maddeningly, the superclass never raises exceptions. If an
FTP operation fails, then the superclass methods generally return false.
A developer then needs to check the
FTP.getReplyCode method to see what actually went wrong. The "strict" methods provided
by this class invoke the superclass method, check if the success flag
is false, and then raise an
FTPException with the value of
FTP.getReplyCode .
author: pjack |
Constructor Summary | |
public | ClientFTP() Constructs a new ClientFTP . |
ClientFTP | public ClientFTP()(Code) | | Constructs a new ClientFTP .
|
connectStrict | public void connectStrict(String host, int port) throws IOException(Code) | | Connects to the FTP server at the given host and port.
Parameters: host - the host of the FTP server to connect to Parameters: port - the port the FTP server listens on throws: IOException - if the connection cannot be made due to IO error throws: FTPException - if the server refuses the connection |
loginStrict | public void loginStrict(String user, String pass) throws IOException(Code) | | Login to the FTP server with the given username and password.
Parameters: user - the username to login under Parameters: pass - the password to use throws: IOException - if a network error occurs throws: FTPException - if the login is rejected by the server throws: org.apache.commons.net.ftp.FTPConnectionClosedException - if the FTP server prematurely closes the connection (for instance, if the client was idle for too long) |
openDataConnection | public Socket openDataConnection(int command, String path) throws IOException(Code) | | Opens a data connection.
Parameters: command - the data command (eg, RETR or LIST) Parameters: path - the path of the file to retrieve the socket to read data from throws: IOException - if a network error occurs throws: FTPException - if a protocol error occurs |
setBinary | public void setBinary() throws IOException(Code) | | Tells the FTP server to send binary files.
throws: IOException - if a network error occurs throws: FTPException - if the server rejects the command throws: org.apache.commons.net.ftp.FTPConnectionClosedException - if the FTP server prematurely closes the connection (for instance, if the client was idle for too long) |
|
|