|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.net.SocketClient
org.apache.commons.net.telnet.TelnetClient
org.apache.commons.net.ftp.FTP
org.apache.commons.net.ftp.FTPClient
org.archive.net.ClientFTP
public class ClientFTP
Client for FTP operations. This class is necessary only because the
FTPClient._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()
.
Field Summary | |
---|---|
protected static int |
TERMINAL_TYPE
|
protected static int |
TERMINAL_TYPE_IS
|
protected static int |
TERMINAL_TYPE_SEND
|
Fields inherited from class org.apache.commons.net.ftp.FTPClient |
---|
ACTIVE_LOCAL_DATA_CONNECTION_MODE, ACTIVE_REMOTE_DATA_CONNECTION_MODE, PASSIVE_LOCAL_DATA_CONNECTION_MODE, PASSIVE_REMOTE_DATA_CONNECTION_MODE |
Fields inherited from class org.apache.commons.net.ftp.FTP |
---|
_commandSupport_, ASCII_FILE_TYPE, BINARY_FILE_TYPE, BLOCK_TRANSFER_MODE, CARRIAGE_CONTROL_TEXT_FORMAT, COMPRESSED_TRANSFER_MODE, DEFAULT_CONTROL_ENCODING, DEFAULT_DATA_PORT, DEFAULT_PORT, EBCDIC_FILE_TYPE, FILE_STRUCTURE, IMAGE_FILE_TYPE, LOCAL_FILE_TYPE, NON_PRINT_TEXT_FORMAT, PAGE_STRUCTURE, RECORD_STRUCTURE, STREAM_TRANSFER_MODE, TELNET_TEXT_FORMAT |
Fields inherited from class org.apache.commons.net.telnet.TelnetClient |
---|
readerThread |
Fields inherited from class org.apache.commons.net.SocketClient |
---|
_defaultPort_, _input_, _isConnected_, _output_, _socket_, _socketFactory_, _timeout_, NETASCII_EOL |
Constructor Summary | |
---|---|
ClientFTP()
Constructs a new ClientFTP . |
Method Summary | |
---|---|
void |
connectStrict(java.lang.String host,
int port)
Connects to the FTP server at the given host and port. |
void |
loginStrict(java.lang.String user,
java.lang.String pass)
Login to the FTP server with the given username and password. |
java.net.Socket |
openDataConnection(int command,
java.lang.String path)
Opens a data connection. |
void |
setBinary()
Tells the FTP server to send binary files. |
Methods inherited from class org.apache.commons.net.ftp.FTPClient |
---|
_connectAction_, _openDataConnection_, abort, allocate, allocate, appendFile, appendFileStream, changeToParentDirectory, changeWorkingDirectory, completePendingCommand, configure, createFileList, createFileList, deleteFile, disconnect, enterLocalActiveMode, enterLocalPassiveMode, enterRemoteActiveMode, enterRemotePassiveMode, getBufferSize, getDataConnectionMode, getPassiveHost, getPassivePort, getRestartOffset, getStatus, getStatus, getSystemName, initiateListParsing, initiateListParsing, initiateListParsing, isRemoteVerificationEnabled, listFiles, listFiles, listFiles, listFiles, listFiles, listHelp, listHelp, listNames, listNames, login, login, logout, makeDirectory, printWorkingDirectory, remoteAppend, remoteRetrieve, remoteStore, remoteStoreUnique, remoteStoreUnique, removeDirectory, rename, retrieveFile, retrieveFileStream, sendNoOp, sendSiteCommand, setBufferSize, setDataTimeout, setFileStructure, setFileTransferMode, setFileType, setFileType, setParserFactory, setRemoteVerificationEnabled, setRestartOffset, storeFile, storeFileStream, storeUniqueFile, storeUniqueFile, storeUniqueFileStream, storeUniqueFileStream, structureMount |
Methods inherited from class org.apache.commons.net.ftp.FTP |
---|
abor, acct, addProtocolCommandListener, allo, allo, appe, cdup, cwd, dele, getControlEncoding, getReply, getReplyCode, getReplyString, getReplyStrings, help, help, list, list, mkd, mode, nlst, nlst, noop, pass, pasv, port, pwd, quit, rein, removeProtocolCommandListener, rest, retr, rmd, rnfr, rnto, sendCommand, sendCommand, sendCommand, sendCommand, setControlEncoding, site, smnt, stat, stat, stor, stou, stou, stru, syst, type, type, user |
Methods inherited from class org.apache.commons.net.telnet.TelnetClient |
---|
addOptionHandler, deleteOptionHandler, getInputStream, getLocalOptionState, getOutputStream, getReaderThread, getRemoteOptionState, registerNotifHandler, registerSpyStream, sendAYT, setReaderThread, stopSpyStream, unregisterNotifHandler |
Methods inherited from class org.apache.commons.net.SocketClient |
---|
connect, connect, connect, connect, connect, connect, getDefaultPort, getDefaultTimeout, getLocalAddress, getLocalPort, getRemoteAddress, getRemotePort, getSoLinger, getSoTimeout, getTcpNoDelay, isConnected, setDefaultPort, setDefaultTimeout, setSocketFactory, setSoLinger, setSoTimeout, setTcpNoDelay, verifyRemote |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int TERMINAL_TYPE
protected static final int TERMINAL_TYPE_SEND
protected static final int TERMINAL_TYPE_IS
Constructor Detail |
---|
public ClientFTP()
ClientFTP
.
Method Detail |
---|
public void connectStrict(java.lang.String host, int port) throws java.io.IOException
host
- the host of the FTP server to connect toport
- the port the FTP server listens on
java.io.IOException
- if the connection cannot be made due to IO error
FTPException
- if the server refuses the connectionpublic void loginStrict(java.lang.String user, java.lang.String pass) throws java.io.IOException
user
- the username to login underpass
- the password to use
java.io.IOException
- if a network error occurs
FTPException
- if the login is rejected by the server
org.apache.commons.net.ftp.FTPConnectionClosedException
- if the FTP server prematurely closes the connection (for
instance, if the client was idle for too long)public void setBinary() throws java.io.IOException
java.io.IOException
- if a network error occurs
FTPException
- if the server rejects the command
org.apache.commons.net.ftp.FTPConnectionClosedException
- if the FTP server prematurely closes the connection (for
instance, if the client was idle for too long)public java.net.Socket openDataConnection(int command, java.lang.String path) throws java.io.IOException
command
- the data command (eg, RETR or LIST)path
- the path of the file to retrieve
java.io.IOException
- if a network error occurs
FTPException
- if a protocol error occurs
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |