|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.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.lang.String |
getLastModifiedTime(java.lang.String remoteName)
|
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 |
java.util.Vector |
list(java.lang.String mask)
Get a directory listing from the remote server. |
static void |
main(java.lang.String[] args)
|
void |
mkdir(java.lang.String remoteName)
Create remote directory |
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 |
rmdir(java.lang.String remoteName)
Delete remote directory |
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. |
java.io.InputStream |
startGet(java.lang.String remoteName)
Start get file Start a file transfer remote file to local inputStream. |
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. |
java.io.InputStream |
startPasvGet(java.lang.String remoteName)
|
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. |
java.io.OutputStream |
startPut(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 |
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 passwordFtpException
- For local problems or negative server responsespublic 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 passwordFtpException
- For local problems or negative server responsesMethod 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 hostFtpException
- For local problems or negative server responsespublic 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.FtpException
- For local problems or negative server responsespublic 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 passwordFtpException
- For local problems or negative server responsespublic void setType(char type) throws FtpException, java.io.IOException
type
- One of Ftp.ASCII, Ftp.EBCDIC or Ftp.IMAGEFtpException
- For local problems or negative server responsesjava.io.IOException
- IOExceptionpublic 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_CONTROLFtpException
- For local problems or negative server responsesjava.io.IOException
- IOExceptionpublic void setType(int length) throws FtpException, java.io.IOException
length
- Length of word.FtpException
- For local problems or negative server responsesjava.io.IOException
- IOExceptionpublic boolean transferComplete() throws FtpException, java.io.IOException
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.public void waitUntilTransferComplete() throws FtpException, java.io.IOException
FtpException
- For local problems or negative server responsesprotected void transferCompleteNotification()
public void startGet(java.lang.String remoteName, java.lang.String localName) throws FtpException, java.io.IOException
remoteName
- Remote file namelocalName
- Local file nameFtpException
- For local problems or negative server responsespublic java.io.InputStream startGet(java.lang.String remoteName) throws FtpException, java.io.IOException
remoteName
- Remote file nameFtpException
- For local problems or negative server responsespublic 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 writtenFtpException
- For local problems or negative server responsespublic void startPut(java.lang.String localName, java.lang.String remoteName) throws FtpException, java.io.IOException
remoteName
- Remote file namelocalName
- Local file nameFtpException
- For local problems or negative server responsespublic java.io.OutputStream startPut(java.lang.String remoteName) throws FtpException, java.io.IOException
remoteName
- Remote file nameFtpException
- For local problems or negative server responsespublic void startPut(java.io.InputStream source, java.lang.String remoteName) throws FtpException, java.io.IOException
remoteName
- Remote file namelocalName
- Local file nameFtpException
- For local problems or negative server responsespublic void startPasvGet(java.lang.String remoteName, java.lang.String localName) throws FtpException, java.io.IOException
remoteName
- Remote file namelocalName
- Local file nameFtpException
- For local problems or negative server responsespublic java.io.InputStream startPasvGet(java.lang.String remoteName) throws FtpException, java.io.IOException
public 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 nameFtpException
- For local problems or negative server responsespublic void startPasvPut(java.io.InputStream source, java.lang.String remoteName) throws FtpException, java.io.IOException
public void mkdir(java.lang.String remoteName) throws FtpException, java.io.IOException
remoteName
- The remote directory nameFtpException
- For local problems or negative server responsespublic 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 passwordFtpException
- For local problems or negative server responsespublic java.lang.String workingDirectory() throws FtpException, java.io.IOException
FtpException
- For local problems or negative server responsespublic void workingDirectory(java.lang.String dir) throws FtpException, java.io.IOException
dir
- The remote working directoryFtpException
- For local problems or negative server responsespublic void rename(java.lang.String oldName, java.lang.String newName) throws FtpException, java.io.IOException
oldName
- The original file namenewName
- The new file nameFtpException
- For local problems or negative server responsespublic void delete(java.lang.String remoteName) throws FtpException, java.io.IOException
remoteName
- The remote file nameFtpException
- For local problems or negative server responsespublic void abort() throws FtpException, java.io.IOException
FtpException
- For local problems or negative server responsespublic java.util.Vector list() throws FtpException, java.io.IOException
FtpException
- For local problems or negative server responsespublic java.lang.String status() throws FtpException, java.io.IOException
FtpException
- For local problems or negative server responsespublic void close() throws java.io.IOException
FtpException
- For local problems or negative server responsespublic 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 void rmdir(java.lang.String remoteName) throws FtpException, java.io.IOException
remoteName
- The remote directory nameFtpException
- For local problems or negative server responsespublic java.lang.String getLastModifiedTime(java.lang.String remoteName) throws FtpException, java.io.IOException
public java.util.Vector list(java.lang.String mask) throws FtpException, java.io.IOException
FtpException
- For local problems or negative server responsespublic static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |