|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.mortbay.FTP.Ftp
FTP Client
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();
Field Summary | |
static java.lang.String |
anonymous
|
static char |
ASCII
|
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(java.net.InetAddress hostAddr,
int port,
java.lang.String username,
java.lang.String password)
Ftp constructor Construct an FTP endpoint, open the command port and authenticate the user. |
|
Ftp(java.net.InetAddress hostAddr,
java.lang.String username,
java.lang.String password)
Ftp constructor Construct an FTP endpoint, open the default command port and authenticate the user. |
Method Summary | |
void |
abort()
Abort transfer command |
void |
authenticate(java.lang.String username,
java.lang.String password)
Authenticate User |
void |
close()
close the FTP session |
void |
delete(java.lang.String remoteName)
Delete remote file |
java.net.InetAddress |
getLocalAddress()
|
void |
getUrl(java.lang.String url,
java.io.OutputStream out)
Get file from a URL spec |
java.util.Vector |
list()
Get list files in remote working directory |
static void |
main(java.lang.String[] args)
|
void |
open(java.net.InetAddress hostAddr)
Open connection |
void |
open(java.net.InetAddress hostAddr,
int port)
Open connection |
void |
rename(java.lang.String oldName,
java.lang.String newName)
Rename remote file |
void |
sendFile(java.lang.String srcName,
java.net.InetAddress destAddr,
int destPort,
java.lang.String username,
java.lang.String password,
java.lang.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(java.lang.String remoteName,
java.io.OutputStream destination)
Start get file Start a file transfer remote file to local file. |
void |
startGet(java.lang.String remoteName,
java.lang.String localName)
Start get file Start a file transfer remote file to local file. |
void |
startPasvGet(java.lang.String remoteName,
java.io.OutputStream destination)
|
void |
startPasvGet(java.lang.String remoteName,
java.lang.String localName)
Start passive get file Start a file transfer remote file to local file. |
void |
startPasvPut(java.io.InputStream source,
java.lang.String remoteName)
|
void |
startPasvPut(java.lang.String localName,
java.lang.String remoteName)
Start passive put file Start a file transfer local file to input remote file. |
void |
startPut(java.io.InputStream source,
java.lang.String remoteName)
Start put file Start a file transfer local file to input remote file. |
void |
startPut(java.lang.String localName,
java.lang.String remoteName)
Start put file Start a file transfer local file to input remote file. |
java.lang.String |
status()
Get remote server status |
static void |
test()
|
boolean |
transferComplete()
Command complete query |
protected void |
transferCompleteNotification()
Transfer completion notification. |
void |
waitUntilTransferComplete()
Wait until Transfer is complete. |
java.lang.String |
workingDirectory()
Report remote working directory |
void |
workingDirectory(java.lang.String dir)
Set remote working directory |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final java.lang.String anonymous
public static final int defaultPort
public static final char ASCII
public static final char LOCAL
public static final char EBCDIC
public static final char IMAGE
public static final char BINARY
public static final char NON_PRINT
public static final char TELNET
public static final char CARRIAGE_CONTROL
Constructor Detail |
public Ftp()
public Ftp(java.net.InetAddress hostAddr, java.lang.String username, java.lang.String password) throws FtpException, java.io.IOException
hostAddr
- The IP address of the remote hostusername
- User name for authentication, null implies no user
requiredpassword
- Password for authentication, null implies no passwordpublic Ftp(java.net.InetAddress hostAddr, int port, java.lang.String username, java.lang.String password) throws FtpException, java.io.IOException
hostAddr
- The IP address of the remote hostport
- 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
requiredpassword
- Password for authentication, null implies no passwordMethod Detail |
public java.net.InetAddress getLocalAddress()
public void open(java.net.InetAddress hostAddr) throws FtpException, java.io.IOException
hostAddr
- The IP address of the remote hostpublic void open(java.net.InetAddress hostAddr, int port) throws FtpException, java.io.IOException
hostAddr
- The IP address of the remote hostport
- The port to use for the control connection. The
default value is used if the port is 0.public void authenticate(java.lang.String username, java.lang.String password) throws FtpException, java.io.IOException
username
- User name for authentication, null implies no user
requiredpassword
- Password for authentication, null implies no passwordpublic void setType(char type) throws FtpException, java.io.IOException
type
- One of Ftp.ASCII, Ftp.EBCDIC or Ftp.IMAGEpublic void setType(char type, char param) throws FtpException, java.io.IOException
type
- One of Ftp.ASCII or Ftp.EBCDICparam
- One of Ftp.NON_PRINT, Ftp.TELNET or Ftp.CARRIAGE_CONTROLpublic void setType(int length) throws FtpException, java.io.IOException
length
- Length of word.public boolean transferComplete() throws FtpException, java.io.IOException
public void waitUntilTransferComplete() throws FtpException, java.io.IOException
protected void transferCompleteNotification()
public void startGet(java.lang.String remoteName, java.lang.String localName) throws FtpException, java.io.IOException
remoteName
- Remote file namelocalName
- Local file namepublic void startGet(java.lang.String remoteName, java.io.OutputStream destination) throws FtpException, java.io.IOException
remoteName
- Remote file namedestination
- OutputStream to which the received file is writtenpublic void startPut(java.lang.String localName, java.lang.String remoteName) throws FtpException, java.io.IOException
remoteName
- Remote file namelocalName
- Local file namepublic void startPut(java.io.InputStream source, java.lang.String remoteName) throws FtpException, java.io.IOException
remoteName
- Remote file namelocalName
- Local file namepublic void startPasvGet(java.lang.String remoteName, java.lang.String localName) throws FtpException, java.io.IOException
remoteName
- Remote file namelocalName
- Local file namepublic void startPasvGet(java.lang.String remoteName, java.io.OutputStream destination) throws FtpException, java.io.IOException
public void startPasvPut(java.lang.String localName, java.lang.String remoteName) throws FtpException, java.io.IOException
remoteName
- Remote file namelocalName
- Local file namepublic void startPasvPut(java.io.InputStream source, java.lang.String remoteName) throws FtpException, java.io.IOException
public void sendFile(java.lang.String srcName, java.net.InetAddress destAddr, int destPort, java.lang.String username, java.lang.String password, java.lang.String destName) throws FtpException, java.io.IOException
srcName
- Remote file name on source serverdestAddr
- The IP address of the destination hostport
- 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
requiredpassword
- Password for authentication, null implies no passwordpublic java.lang.String workingDirectory() throws FtpException, java.io.IOException
public void workingDirectory(java.lang.String dir) throws FtpException, java.io.IOException
dir
- The remote working directorypublic void rename(java.lang.String oldName, java.lang.String newName) throws FtpException, java.io.IOException
oldName
- The original file namenewName
- The new file namepublic void delete(java.lang.String remoteName) throws FtpException, java.io.IOException
remoteName
- The remote file namepublic void abort() throws FtpException, java.io.IOException
public java.util.Vector list() throws FtpException, java.io.IOException
public java.lang.String status() throws FtpException, java.io.IOException
public void close() throws java.io.IOException
public void getUrl(java.lang.String url, java.io.OutputStream out) throws FtpException, java.io.IOException
url
- string of the form:
"ftp://username:password@host:port/path/to/file"out
- the OutputStream to place the fetched file inpublic static void main(java.lang.String[] args)
public static void test()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |