org.mortbay.ftp
public class Ftp extends Object
File Transfer Protocol client class. Provides basic FTP client functionality in an Asynchronous interface.
see rfc959.
Ftp ftp = new Ftp(InetAddress.getByName("RemoteHost"), "TestUser", "TestPass"); ftp.setType(Ftp.IMAGE); ftp.startGet("RemoteFileName", "LocalFileName"); ftp.waitUntilTransferComplete(); ftp.startPut("LocalFileName", "RemoteFileName"); ftp.waitUntilTransferComplete();
Version: $Id: Ftp.java,v 1.5 2005/06/04 13:38:25 gregwilkins Exp $
Field Summary | |
---|---|
static char | ASCII |
static String | anonymous |
static char | BINARY |
static char | CARRIAGE_CONTROL |
static int | defaultPort |
static char | EBCDIC |
static char | IMAGE |
static char | LOCAL |
static char | NON_PRINT |
static char | TELNET |
Constructor Summary | |
---|---|
Ftp()
Ftp constructor | |
Ftp(InetAddress hostAddr, String username, String password)
Ftp constructor Construct an FTP endpoint, open the default command port and authenticate the
user.
| |
Ftp(InetAddress hostAddr, int port, String username, String password)
Ftp constructor Construct an FTP endpoint, open the command port and authenticate the user.
|
Method Summary | |
---|---|
void | abort()
Abort transfer command
|
void | authenticate(String username, String password)
Authenticate User
|
void | close()
close the FTP session
|
void | delete(String remoteName)
Delete remote file
|
String | getLastModifiedTime(String remoteName) |
InetAddress | getLocalAddress() |
String | getSize(String remoteName) |
void | getUrl(String url, OutputStream out)
Get file from a URL spec
|
Vector | list()
Get list files in remote working directory
|
Vector | list(String mask)
Get a directory listing from the remote server.
|
static void | main(String[] args) |
void | mkdir(String remoteName)
Create remote directory
|
void | open(InetAddress hostAddr)
Open connection
|
void | open(InetAddress hostAddr, int port)
Open connection
|
void | rename(String oldName, String newName)
Rename remote file
|
void | rmdir(String remoteName)
Delete remote directory
|
void | sendFile(String srcName, InetAddress destAddr, int destPort, String username, String password, String destName)
send file Do a file transfer remote file to remote file on another server. |
void | setType(char type)
Set the connection data type. |
void | setType(char type, char param)
Set the connection data type. |
void | setType(int length)
Set the connection data type to Local. |
void | startGet(String remoteName, String localName)
Start get file Start a file transfer remote file to local file. |
InputStream | startGet(String remoteName)
Start get file Start a file transfer remote file to local inputStream. |
void | startGet(String remoteName, OutputStream destination)
Start get file Start a file transfer remote file to local file. |
void | startPasvGet(String remoteName, String localName)
Start passive get file Start a file transfer remote file to local file. |
void | startPasvGet(String remoteName, OutputStream destination) |
void | startPasvPut(String localName, String remoteName)
Start passive put file Start a file transfer local file to input remote file. |
void | startPasvPut(InputStream source, String remoteName) |
void | startPut(String localName, String remoteName)
Start put file Start a file transfer local file to input remote file. |
OutputStream | startPut(String remoteName)
Start put file Start a file transfer local file to input remote file. |
void | startPut(InputStream source, String remoteName)
Start put file Start a file transfer local file to input remote file. |
String | status()
Get remote server status
|
boolean | transferComplete()
Command complete query
|
protected void | transferCompleteNotification()
Transfer completion notification. |
void | waitUntilTransferComplete()
Wait until Transfer is complete. |
String | workingDirectory()
Report remote working directory
|
void | workingDirectory(String dir)
Set remote working directory
|
Parameters: hostAddr The IP address of the remote host username User name for authentication, null implies no user required password Password for authentication, null implies no password
Throws: FtpException For local problems or negative server responses
Parameters: hostAddr The IP address of the remote host port The port to use for the control connection. The default value is used if the port is 0. username User name for authentication, null implies no user required password Password for authentication, null implies no password
Throws: FtpException For local problems or negative server responses
Throws: FtpException For local problems or negative server responses
Parameters: username User name for authentication, null implies no user required password Password for authentication, null implies no password
Throws: FtpException For local problems or negative server responses
Throws: FtpException For local problems or negative server responses
Parameters: remoteName The remote file name
Throws: FtpException For local problems or negative server responses
Parameters: remoteName The remote file name
Returns: Last modified time string.
Throws: FtpException For local problems or negative server responses
Parameters: remoteName The remote file name
Returns: The size of the remote file
Throws: FtpException For local problems or negative server responses
Parameters: url string of the form: "ftp://username:password@host:port/path/to/file" out the OutputStream to place the fetched file in
Returns: Array of file names
Throws: FtpException For local problems or negative server responses
Returns: Array of file information.
Throws: FtpException For local problems or negative server responses
Parameters: remoteName The remote directory name
Throws: FtpException For local problems or negative server responses
Parameters: hostAddr The IP address of the remote host
Throws: FtpException For local problems or negative server responses
Parameters: hostAddr The IP address of the remote host port The port to use for the control connection. The default value is used if the port is 0.
Throws: FtpException For local problems or negative server responses
Parameters: oldName The original file name newName The new file name
Throws: FtpException For local problems or negative server responses
Parameters: remoteName The remote directory name
Throws: FtpException For local problems or negative server responses
Parameters: srcName Remote file name on source server destAddr The IP address of the destination host destPort The port to use for the control connection. The default value is used if the port is 0. username User name for authentication, null implies no user required password Password for authentication, null implies no password
Throws: FtpException For local problems or negative server responses
Parameters: type One of Ftp.ASCII, Ftp.EBCDIC or Ftp.IMAGE
Throws: FtpException For local problems or negative server responses IOException IOException
Parameters: type One of Ftp.ASCII or Ftp.EBCDIC param One of Ftp.NON_PRINT, Ftp.TELNET or Ftp.CARRIAGE_CONTROL
Throws: FtpException For local problems or negative server responses IOException IOException
Parameters: length Length of word.
Throws: FtpException For local problems or negative server responses IOException IOException
Parameters: remoteName Remote file name localName Local file name
Throws: FtpException For local problems or negative server responses
Parameters: remoteName Remote file name
Returns: InputStream, the data fetched may be read from this inputStream.
Throws: FtpException For local problems or negative server responses
Parameters: remoteName Remote file name destination OutputStream to which the received file is written
Throws: FtpException For local problems or negative server responses
Parameters: remoteName Remote file name localName Local file name
Throws: FtpException For local problems or negative server responses
Parameters: remoteName Remote file name localName Local file name
Throws: FtpException For local problems or negative server responses
Parameters: remoteName Remote file name localName Local file name
Throws: FtpException For local problems or negative server responses
Parameters: remoteName Remote file name
Returns: OutputStream Data written to this output stream is sent to the remote file.
Throws: FtpException For local problems or negative server responses
Parameters: remoteName Remote file name source
Throws: FtpException For local problems or negative server responses
Returns: String description of server status
Throws: FtpException For local problems or negative server responses
Returns: true if the no outstanding command is in progress, false if there is an outstanding command or data transfer.
Throws: FtpException For local problems or negative server responses. The problem may have been detected before the call to complete during a data transfer, but is only reported when the call to complete is made.
Throws: FtpException For local problems or negative server responses
Returns: The remote working directory
Throws: FtpException For local problems or negative server responses
Parameters: dir The remote working directory
Throws: FtpException For local problems or negative server responses