public class Client
extends org.apache.commons.net.ftp.FTP
Modifier and Type | Field and Description |
---|---|
protected static int |
TERMINAL_TYPE |
protected static int |
TERMINAL_TYPE_IS |
protected static int |
TERMINAL_TYPE_SEND |
_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
Constructor and Description |
---|
Client()
Public default constructor
|
Modifier and Type | Method and Description |
---|---|
protected Socket |
__openPassiveDataConnection(int command,
String arg)
open a passive data connection socket
|
void |
disconnect()
Closes the connection to the FTP server and restores connection parameters
to the default values.
|
String |
getSystemName()
Fetches the system type name from the server and returns the string.
|
boolean |
isRemoteVerificationEnabled()
Return whether or not verification of the remote host participating in data
connections is enabled.
|
boolean |
login(String username,
String password)
Login to the FTP server using the provided username and password.
|
boolean |
logout()
Logout of the FTP server by sending the QUIT command.
|
void |
retrieveFile(String path,
OutputStream os,
int limit)
retrieve file for path
|
void |
retrieveList(String path,
List<org.apache.commons.net.ftp.FTPFile> entries,
int limit,
org.apache.commons.net.ftp.FTPFileEntryParser parser)
retrieve list reply for path
|
boolean |
sendNoOp()
Sends a NOOP command to the FTP server.
|
void |
setDataTimeout(int timeout)
Sets the timeout in milliseconds to use for data connection.
|
boolean |
setFileType(int fileType)
Sets the file type to be transferred.
|
void |
setRemoteVerificationEnabled(boolean enable)
Enable or disable verification that the remote host taking part of a data
connection is the same as the host to which the control connection is
attached.
|
_connectAction_, 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
addOptionHandler, deleteOptionHandler, getInputStream, getLocalOptionState, getOutputStream, getReaderThread, getRemoteOptionState, registerNotifHandler, registerSpyStream, sendAYT, setReaderThread, stopSpyStream, unregisterNotifHandler
connect, connect, connect, connect, connect, connect, getDefaultPort, getDefaultTimeout, getLocalAddress, getLocalPort, getRemoteAddress, getRemotePort, getSoLinger, getSoTimeout, getTcpNoDelay, isConnected, setDefaultPort, setDefaultTimeout, setSocketFactory, setSoLinger, setSoTimeout, setTcpNoDelay, verifyRemote
protected static final int TERMINAL_TYPE
protected static final int TERMINAL_TYPE_SEND
protected static final int TERMINAL_TYPE_IS
protected Socket __openPassiveDataConnection(int command, String arg) throws IOException, FtpExceptionCanNotHaveDataConnection
command
- arg
- IOException
FtpExceptionCanNotHaveDataConnection
public void setDataTimeout(int timeout)
public void disconnect() throws IOException
disconnect
in class org.apache.commons.net.ftp.FTP
IOException
- If an error occurs while disconnecting.public void setRemoteVerificationEnabled(boolean enable)
enable
- True to enable verification, false to disable verification.public boolean isRemoteVerificationEnabled()
public boolean login(String username, String password) throws IOException
username
- The username to login under.password
- The password to use.org.apache.commons.net.ftp.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a
result of the client being idle or some other reason causing
the server to send FTP reply code 421. This exception may be
caught either as an IOException or independently as itself.IOException
- If an I/O error occurs while either sending a command to the
server or receiving a reply from the server.public boolean logout() throws IOException
org.apache.commons.net.ftp.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a
result of the client being idle or some other reason causing
the server to send FTP reply code 421. This exception may be
caught either as an IOException or independently as itself.IOException
- If an I/O error occurs while either sending a command to the
server or receiving a reply from the server.public void retrieveList(String path, List<org.apache.commons.net.ftp.FTPFile> entries, int limit, org.apache.commons.net.ftp.FTPFileEntryParser parser) throws IOException, FtpExceptionCanNotHaveDataConnection, FtpExceptionUnknownForcedDataClose, FtpExceptionControlClosedByForcedDataClose
path
- entries
- limit
- parser
- IOException
FtpExceptionCanNotHaveDataConnection
FtpExceptionUnknownForcedDataClose
FtpExceptionControlClosedByForcedDataClose
public void retrieveFile(String path, OutputStream os, int limit) throws IOException, FtpExceptionCanNotHaveDataConnection, FtpExceptionUnknownForcedDataClose, FtpExceptionControlClosedByForcedDataClose
path
- os
- limit
- IOException
FtpExceptionCanNotHaveDataConnection
FtpExceptionUnknownForcedDataClose
FtpExceptionControlClosedByForcedDataClose
public boolean setFileType(int fileType) throws IOException
FTP.ASCII_FILE_TYPE
, FTP.IMAGE_FILE_TYPE
,
etc. The file type only needs to be set when you want to change the type.
After changing it, the new type stays in effect until you change it again.
The default file type is FTP.ASCII_FILE_TYPE
if this method
is never called.
fileType
- The _FILE_TYPE
constant indcating the type of file.org.apache.commons.net.ftp.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a
result of the client being idle or some other reason causing
the server to send FTP reply code 421. This exception may be
caught either as an IOException or independently as itself.IOException
- If an I/O error occurs while either sending a command to the
server or receiving a reply from the server.public String getSystemName() throws IOException, FtpExceptionBadSystResponse
org.apache.commons.net.ftp.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a
result of the client being idle or some other reason causing
the server to send FTP reply code 421. This exception may be
caught either as an IOException or independently as itself.IOException
- If an I/O error occurs while either sending a command to the
server or receiving a reply from the server.FtpExceptionBadSystResponse
public boolean sendNoOp() throws IOException
org.apache.commons.net.ftp.FTPConnectionClosedException
- If the FTP server prematurely closes the connection as a
result of the client being idle or some other reason causing
the server to send FTP reply code 421. This exception may be
caught either as an IOException or independently as itself.IOException
- If an I/O error occurs while either sending a command to the
server or receiving a reply from the server.Copyright © 2015 The Apache Software Foundation