|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.glub.secureftp.bean.FTP
public class FTP
The FTP class is responsible for handling the basic operations
of the File Transfer Protocol.
| Field Summary | |
|---|---|
static short |
ACTIVE_CONNECTION_TYPE
Used to set the data connection type to active. |
static short |
ASCII_TRANSFER_MODE
Used to set the data transfer mode to ascii. |
static short |
AUTO_TRANSFER_MODE
Used to set the data transfer mode to auto. |
static short |
BINARY_TRANSFER_MODE
Used to set the data transfer mode to binary; also
known as image. |
protected FTPCommand |
command
This handles the FTP commands. |
protected boolean |
isConnected
If we are connected, this is true. |
protected boolean |
isLoggedIn
If we are logged in, this is true. |
protected boolean |
modeZEnabled
If mode z is enabled, this is true. |
static short |
PASSIVE_CONNECTION_TYPE
Used to set the data connection type to passive. |
static short |
PASV_CONNECTION_TYPE
Used to set the data connection type to passive. |
protected OutputStream |
recvCmdStream
This stream is used to print the responses returned from the server. |
protected OutputStream |
sendCmdStream
This stream is used to print the commands sent to the server. |
| Constructor Summary | |
|---|---|
FTP(HostInfo hostInfo)
Create a new FTP object without response notification. |
|
FTP(HostInfo hostInfo,
OutputStream sendCmdStream,
OutputStream recvCmdStream)
Create a new FTP object with response notification. |
|
FTP(String host,
int port)
Create a new FTP object without response notification. |
|
FTP(String host,
int port,
OutputStream sendCmdStream,
OutputStream recvCmdStream)
Create a new FTP object with response notification. |
|
| Method Summary | |
|---|---|
void |
abort(FTPAbortableTransfer abort)
Abort a data transfer from the FTP server. |
protected void |
aboutToTransferData()
Called before data transfers begin. |
void |
append(File file,
RemoteFile appendTo)
Append to a file on the FTP server. |
void |
append(File file,
RemoteFile appendTo,
FTPAbortableTransfer abort)
Append to a file on the FTP server with the ability to abort the data transfer. |
void |
append(File file,
RemoteFile appendTo,
Progress progress)
Append to a file on the FTP server with progress information. |
void |
append(File file,
RemoteFile appendTo,
Progress progress,
FTPAbortableTransfer abort)
Append to a file on the FTP server with progress information and the ability to abort the data transfer. |
void |
append(File file,
String appendTo)
Append to a file on the FTP server. |
void |
append(File file,
String appendTo,
FTPAbortableTransfer abort)
Append to a file on the FTP server with the ability to abort the data transfer. |
void |
append(File file,
String appendTo,
Progress progress)
Append to a file on the FTP server with progress information. |
void |
append(File file,
String appendTo,
Progress progress,
FTPAbortableTransfer abort)
Append to a file on the FTP server with progress information and the ability to abort the data transfer. |
void |
append(InputStream inputStream,
long localFileSize,
RemoteFile appendTo,
Progress progress)
Append to a file on the FTP server with progress information. |
void |
append(InputStream inputStream,
long localFileSize,
RemoteFile appendTo,
Progress progress,
FTPAbortableTransfer abort)
Append to a file on the FTP server with progress information and the ability to abort the data transfer. |
void |
append(InputStream inputStream,
long localFileSize,
String appendTo,
Progress progress)
Append to a file on the FTP server with progress information. |
void |
append(InputStream inputStream,
long localFileSize,
String appendTo,
Progress progress,
FTPAbortableTransfer abort)
Append to a file on the FTP server with progress information and the ability to abort the data transfer. |
void |
append(InputStream inputStream,
RemoteFile appendTo)
Append to a file on the FTP server. |
void |
append(InputStream inputStream,
RemoteFile appendTo,
FTPAbortableTransfer abort)
Append to a file on the FTP server with the ability to abort the data transfer. |
void |
append(InputStream inputStream,
String appendTo)
Append to a file on the FTP server. |
void |
append(InputStream inputStream,
String appendTo,
FTPAbortableTransfer abort)
Append to a file on the FTP server with the ability to abort the data transfer. |
void |
ascii()
Set the data transfer mode to ascii. |
void |
auto()
Set the data transfer mode to auto. |
void |
binary()
Set the data transfer mode to binary (or image). |
void |
cdup()
Change up one directory on the FTP server. |
void |
chdir(RemoteFile dir)
Change to a remote directory on the FTP server. |
void |
chdir(String dir)
Change to a remote directory on the FTP server. |
void |
connect()
Connect to the FTP host and port. |
void |
delete(RemoteFile fileName)
Delete a file from the FTP server. |
void |
delete(String fileName)
Delete a file from the FTP server. |
void |
forcePasvToUseControlIP(boolean on)
Forces passive data transfers to use the control socket IP address. |
String |
getAccount()
Get the account name. |
int |
getConnectionType()
The data connection type is either passive or active. |
Socket |
getControlSocket()
Get the control socket. |
static String |
getDateStamp()
The datestamp of the bean. |
FTPCommand |
getFTPCommand()
Get the FTPCommand object. |
String |
getHostName()
Get the hostname of the FTP server. |
short |
getListStyle()
Get the server listing style of the FTP server. |
String |
getPassword()
Get the password. |
int |
getPort()
Get the port of the FTP server. |
short |
getTransferMode()
The data transfer mode is either auto, ascii, or binary (image). |
String |
getUser()
Get the username. |
static String |
getVersion()
The version of the bean. |
String |
help(String item)
Get the server's remote help. |
boolean |
isConnected()
Whether or not currently connected. |
boolean |
isLoggedIn()
Whether or not currently logged in. |
boolean |
isTransferRestartable()
Whether or not the server supports restarting broken data transfers. |
RemoteFileList |
list()
List the current remote directory. |
RemoteFileList |
list(FTPAbortableTransfer abort)
List the current remote directory with the ability to abort the listing. |
RemoteFileList |
list(RemoteFile file)
List items on the remote FTP server. |
RemoteFileList |
list(RemoteFile file,
FTPAbortableTransfer abort,
boolean showHidden)
List items on the remote FTP server with the ability to abort the listing. |
RemoteFileList |
list(String itemsToList)
List items on the remote FTP server. |
RemoteFileList |
list(String itemsToList,
FTPAbortableTransfer abort,
boolean showHidden)
List items on the remote FTP server with the ability to abort the listing. |
RemoteFileList |
listAll()
List the current remote directory, including hidden files. |
RemoteFileList |
listAll(FTPAbortableTransfer abort)
List the current remote directory including hidden files with the ability to abort the listing. |
void |
login(String user,
String pass)
Login to the FTP server. |
void |
login(String user,
String pass,
String acct)
Login to the FTP server. |
void |
logout()
Logout from the FTP server. |
protected Socket |
makeControlSocket(HostInfo hostInfo)
Make a new control socket. |
protected ServerSocket |
makeDataServerSocket(HostInfo hostInfo)
Make a new data server socket. |
protected Socket |
makeDataSocket(HostInfo hostInfo)
Make a new data socket. |
protected FTPCommand |
makeFTPCommand(BufferedReader inputReader,
PrintWriter outputWriter)
Set the FTPCommand object. |
void |
mkdir(String newDir)
Make a new directory on the FTP server. |
void |
modeZ()
Set mode z (on-the-fly compression) data transfer. |
void |
noop()
Send a noop command to the FTP server. |
protected HostInfo |
pasv()
Setup a pasv data connection. |
protected void |
port(HostInfo hostInfo)
Setup an active data connection. |
String |
pwd()
Get the current directory on the FTP server. |
void |
raw(String rawCmd)
Send a raw command to the FTP server. |
void |
rename(String from,
String to)
Rename a file on the FTP server. |
void |
retrieve(RemoteFile remoteFile,
File outputFile,
boolean restartXfer)
Retrieve a file from the FTP server. |
void |
retrieve(RemoteFile remoteFile,
File outputFile,
boolean restartXfer,
FTPAbortableTransfer abort)
Retrieve a file from the FTP server with the ability to abort the transfer. |
void |
retrieve(RemoteFile remoteFile,
File outputFile,
boolean restartXfer,
Progress progress)
Retrieve a file from the FTP server with progress information. |
void |
retrieve(RemoteFile remoteFile,
File outputFile,
boolean restartXfer,
Progress progress,
FTPAbortableTransfer abort)
Retrieve a file from the FTP server with progress information and the ability to abort the transfer. |
void |
retrieve(RemoteFile remoteFile,
OutputStream outputStream)
Retrieve a file from the FTP server. |
void |
retrieve(RemoteFile remoteFile,
OutputStream outputStream,
FTPAbortableTransfer abort)
Retrieve a file from the FTP server with the ability to abort the transfer. |
void |
retrieve(RemoteFile remoteFile,
OutputStream outputStream,
Progress progress)
Retrieve a file from the FTP server with progress information. |
void |
retrieve(RemoteFile remoteFile,
OutputStream outputStream,
Progress progress,
FTPAbortableTransfer abort)
Retrieve a file from the FTP server with progress information and the ability to abort the transfer. |
void |
retrieve(String remoteFile,
File outputFile,
boolean restartXfer)
Retrieve a file from the FTP server. |
void |
retrieve(String remoteFile,
File outputFile,
boolean restartXfer,
FTPAbortableTransfer abort)
Retrieve a file from the FTP server with the ability to abort the transfer. |
void |
retrieve(String remoteFile,
File outputFile,
boolean restartXfer,
Progress progress)
Retrieve a file from the FTP server with progress information. |
void |
retrieve(String remoteFile,
File outputFile,
boolean restartXfer,
Progress progress,
FTPAbortableTransfer abort)
Retrieve a file from the FTP server with progress information and the ability to abort the transfer. |
void |
retrieve(String remoteFile,
OutputStream outputStream)
Retrieve a file from the FTP server. |
void |
retrieve(String remoteFile,
OutputStream outputStream,
FTPAbortableTransfer abort)
Retrieve a file from the FTP server with the ability to abort the transfer. |
void |
retrieve(String remoteFile,
OutputStream outputStream,
Progress progress)
Retrieve a file from the FTP server with progress information. |
void |
retrieve(String remoteFile,
OutputStream outputStream,
Progress progress,
FTPAbortableTransfer abort)
Retrieve a file from the FTP server with progress information and the ability to abort the transfer. |
void |
rmdir(RemoteFile dir)
Remote a directory from the FTP server. |
void |
rmdir(String dir)
Remote a directory from the FTP server. |
void |
sendAccount(String acct)
Sends the account to the FTP server. |
void |
sendPassword(String pass)
Sends the password to the FTP server. |
void |
sendUserName(String user)
Sends the username to the FTP server. |
void |
setAccount(String account)
Set the account name. |
void |
setConnectionType(short type)
Set the data connection type. |
protected void |
setControlSocket(Socket controlSocket)
Set the control socket. |
void |
setHostName(String hostName)
Set the hostname of the FTP server. |
void |
setListStyle(short listStyle)
Set the server type to help with the listing style of the FTP server. |
void |
setPassword(String password)
Set the password. |
void |
setPort(int port)
Set the port of the FTP server. |
void |
setRecvCmdStream(OutputStream recvCmdStream)
Set the stream responsible for handling respones from the FTP server. |
void |
setSendCmdStream(OutputStream sendCmdStream)
Set the stream responsible for handling commands sent to the FTP server. |
void |
setSocksIVProxy(String host,
int port)
Set the Socks IV server proxy. |
void |
setSocksVProxy(String host,
int port,
String username,
String password)
Set the Socks V server proxy. |
void |
setStringDataAsUTF8(boolean on)
Set server to treat string data in UTF8 format |
void |
setUser(String user)
Set the username. |
long |
size(RemoteFile file)
Get the size of a file on the FTP server. |
long |
size(String file)
Get the size of a file on the FTP server. |
void |
store(File file,
boolean restartXfer)
Store a file to the FTP server. |
void |
store(File file,
boolean restartXfer,
FTPAbortableTransfer abort)
Store a file to the FTP server with the ability to abort the data transfer. |
void |
store(File file,
boolean restartXfer,
Progress progress)
Store a file to the FTP server with progress information. |
void |
store(File file,
boolean restartXfer,
Progress progress,
FTPAbortableTransfer abort)
Store a file to the FTP server with progress information and the ability to abort the data transfer. |
void |
store(File file,
String name,
boolean restartXfer)
Store a file to the FTP server with a specific filename. |
void |
store(File file,
String name,
boolean restartXfer,
FTPAbortableTransfer abort)
Store a file to the FTP server with a specific filename and with the ability to abort the data transfer. |
void |
store(File file,
String name,
boolean restartXfer,
Progress progress)
Store a file to the FTP server with a specific filename and with progress information. |
void |
store(File file,
String name,
boolean restartXfer,
Progress progress,
FTPAbortableTransfer abort)
Store a file to the FTP server with a specific filename and progress information and the ability to abort the data transfer. |
void |
store(InputStream inputStream)
Store a file to the FTP server. |
void |
store(InputStream inputStream,
FTPAbortableTransfer abort)
Store a file to the FTP server with the ability to abort the data transfer. |
void |
store(InputStream inputStream,
long localFileSize,
Progress progress)
Store a file to the FTP server with progress information. |
void |
store(InputStream inputStream,
long localFileSize,
Progress progress,
FTPAbortableTransfer abort)
Store a file to the FTP server with progress information and the ability to abort the data transfer. |
void |
store(InputStream inputStream,
long localFileSize,
String name,
Progress progress)
Store a file to the FTP server with a specific filename and with progress information. |
void |
store(InputStream inputStream,
long localFileSize,
String name,
Progress progress,
FTPAbortableTransfer abort)
Store a file to the FTP server with a specific filename and progress information and the ability to abort the data transfer. |
void |
store(InputStream inputStream,
String name)
Store a file to the FTP server with a specific filename. |
void |
store(InputStream inputStream,
String name,
FTPAbortableTransfer abort)
Store a file to the FTP server with a specific filename and with the ability to abort the data transfer. |
boolean |
stringDataAsUTF8()
Whether or not the server is treating the string data as UTF8 |
Date |
time(RemoteFile file)
Get the modification time of a file on the FTP server. |
Date |
time(String file)
Get the modification time of a file on the FTP server. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final short ASCII_TRANSFER_MODE
ascii.
public static final short BINARY_TRANSFER_MODE
binary; also
known as image.
public static final short AUTO_TRANSFER_MODE
auto. This mode
attempts to guess which transfer mode (ascii or binary) to set
based on file type.
public static final short PASV_CONNECTION_TYPE
passive.
public static final short PASSIVE_CONNECTION_TYPE
passive.
public static final short ACTIVE_CONNECTION_TYPE
active.
protected boolean modeZEnabled
protected boolean isConnected
protected boolean isLoggedIn
protected OutputStream recvCmdStream
protected OutputStream sendCmdStream
protected FTPCommand command
| Constructor Detail |
|---|
public FTP(HostInfo hostInfo)
FTP object without response notification.
hostInfo - the HostInfo to connect to.
public FTP(String host,
int port)
FTP object without response notification.
host - the hostname to connect to.port - the port to connect to.
public FTP(HostInfo hostInfo,
OutputStream sendCmdStream,
OutputStream recvCmdStream)
FTP object with response notification.
hostInfo - the HostInfo to connect to.sendCmdStream - the commands sent to the server.
Pass null if not interested
in this data.recvCmdStream - the responses returned from the server.
Pass null if not interested
in this data.
public FTP(String host,
int port,
OutputStream sendCmdStream,
OutputStream recvCmdStream)
FTP object with response notification.
host - the hostname to connect to.port - the port to connect to.sendCmdStream - the commands sent to the server.
Pass null if not interested
in this data.recvCmdStream - the responses returned from the server.
Pass null if not interested
in this data.| Method Detail |
|---|
public void connect()
throws FTPConnectException,
FTPException,
IOException,
UnknownHostException,
IllegalArgumentException
FTPConnectException - if the connection fails.
FTPException - if the FTP server returns an error code.
IOException - if there are socket problems.
UnknownHostException - if the host could not be found.
IllegalArgumentException - if hostName is
null.
public void login(String user,
String pass)
throws IOException,
FTPBadLoginException,
FTPConnectException,
FTPException,
IllegalArgumentException
user - the username to login as.pass - the password to login as.
IOException - if there is a socket problem.
FTPBadLoginException - if there is a problem logging in.
FTPConnectException - if this is called prior to
connect
FTPException - if the FTP server returns an error code.
IllegalArgumentException - if there is a problem with any of the
passed in args.connect()
public void login(String user,
String pass,
String acct)
throws IOException,
FTPBadLoginException,
FTPConnectException,
FTPException,
IllegalArgumentException
user - the username to login as.pass - the password to login as.acct - the account to use.
IOException - if there is a socket problem.
FTPBadLoginException - if there is a problem logging in.
FTPConnectException - if this is called prior to
connect
FTPException - if the FTP server returns an error code.
IllegalArgumentException - if there is a problem with any of the
passed in args.connect()
public void logout()
throws IOException,
FTPException
IOException - if there is a socket problem.
FTPException - if the FTP server returns an error code.
public void sendUserName(String user)
throws FTPNeedPasswordException,
FTPNeedAccountException,
FTPBadLoginException,
FTPException,
IllegalArgumentException
user - the username.
FTPNeedPasswordException - if a password is required.
FTPNeedAccountException - if an accound is required.
FTPBadLoginException - if there is a problem logging in.
FTPException - if the FTP server returns an error code.
IllegalArgumentException - if there is a problem with the username.
public void sendPassword(String pass)
throws FTPNeedAccountException,
FTPBadLoginException,
FTPException,
IllegalArgumentException
pass - the password.
FTPNeedAccountException - if an accound is required.
FTPBadLoginException - if there is a problem logging in.
FTPException - if the FTP server returns an error code.
IllegalArgumentException - if there is a problem with the password.
public void sendAccount(String acct)
throws FTPBadLoginException,
FTPException,
IllegalArgumentException
acct - the account.
FTPBadLoginException - if there is a problem logging in.
FTPException - if the FTP server returns an error code.
IllegalArgumentException - if there is a problem with the account.
public RemoteFileList listAll()
throws FTPException,
IOException
Based on what getConnectionType returns, either
pasv or port will be sent in this routine.
RemoteFile objects as a
RemoteFileList.
FTPException - if the FTP server returns an error code.
IOException - if there is a socket problem.RemoteFile,
getConnectionType(),
setConnectionType(short),
pasv(),
port(HostInfo)
public RemoteFileList list()
throws FTPException,
IOException
Based on what getConnectionType returns, either
pasv or port will be sent in this routine.
RemoteFile objects as a
RemoteFileList.
FTPException - if the FTP server returns an error code.
IOException - if there is a socket problem.RemoteFile,
getConnectionType(),
setConnectionType(short),
pasv(),
port(HostInfo)
public RemoteFileList list(FTPAbortableTransfer abort)
throws FTPException,
IOException
Based on what getConnectionType returns, either
pasv or port will be sent in this routine.
abort - an Object that allows for the abortion of the
list.
RemoteFile objects as a
RemoteFileList.
FTPException - if the FTP server returns an error code.
IOException - if there is a socket problem.RemoteFile,
getConnectionType(),
setConnectionType(short),
pasv(),
port(HostInfo)
public RemoteFileList listAll(FTPAbortableTransfer abort)
throws FTPException,
IOException
Based on what getConnectionType returns, either
pasv or port will be sent in this routine.
abort - an Object that allows for the abortion of the
list.
RemoteFile objects as a
RemoteFileList.
FTPException - if the FTP server returns an error code.
IOException - if there is a socket problem.RemoteFile,
getConnectionType(),
setConnectionType(short),
pasv(),
port(HostInfo)
public RemoteFileList list(RemoteFile file)
throws FTPException,
IOException
Based on what getConnectionType returns, either
pasv or port will be sent in this routine.
file - a RemoteFile you
want to to list from the FTP server.
Pass null to list the current directory.
RemoteFile objects as a
RemoteFileList.
FTPException - if the FTP server returns an error code.
IOException - if there is a socket problem.RemoteFile,
getConnectionType(),
setConnectionType(short),
pasv(),
port(HostInfo)
public RemoteFileList list(String itemsToList)
throws FTPException,
IOException
Based on what getConnectionType returns, either
pasv or port will be sent in this routine.
itemsToList - a space-delimited String of items you
want to to list from the FTP server.
Pass null to list the current directory.
RemoteFile objects as a
RemoteFileList.
FTPException - if the FTP server returns an error code.
IOException - if there is a socket problem.RemoteFile,
getConnectionType(),
setConnectionType(short),
pasv(),
port(HostInfo)
public RemoteFileList list(RemoteFile file,
FTPAbortableTransfer abort,
boolean showHidden)
throws FTPException,
IOException