|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.jftp.net.FtpConnection
All control transactions are made here. See doc/FtpDownload.java for examples and note that this class is event-driven and not Exception-based! You might want to take a look at ConnectionListener, too.
| Field Summary | |
static java.lang.String |
ABOR
Internal abort command constant |
static java.lang.String |
ASCII
|
static java.lang.String |
BINARY
|
static java.lang.String |
BLOCKED
|
static java.lang.String |
COMPRESSED
|
static java.lang.String |
DOWNLOAD
Internal download constant |
static java.lang.String |
EBCDIC
|
boolean |
hasUploaded
Used to determine the type of transfer. |
static java.lang.String |
L8
|
static java.lang.String |
STREAM
|
static java.lang.String |
UPLOAD
Internal upload constant |
boolean |
work
|
| Fields inherited from interface net.sf.jftp.net.FtpConstants |
ACCT, ADAT, ALLO, APPE, AUTH, CCC, CDUP, CHDIR_FAILED, CONF, CWD, DELE, DENIED, ENC, FILE_NOT_FOUND, FTP200_OK, FTP215_SYSTEM_TYPE, FTP220_SERVICE_READY, FTP221_SERVICE_CLOSING, FTP226_CLOSING_DATA_REQUEST_SUCCESSFUL, FTP227_ENTERING_PASSIVE_MODE, FTP230_LOGGED_IN, FTP250_COMPLETED, FTP257_PATH_CREATED, FTP331_USER_OK_NEED_PASSWORD, GENERIC_FAILED, HELP, LIST, LOGIN_OK, MIC, MKD, MKDIR_FAILED, MODE, NEW_TRANSFER_SPAWNED, NLST, NOOP, OFFLINE, PASS, PASV, PBSZ, PERMISSION_DENIED, PORT, PROT, PWD, QUIT, R, RC110, RC120, RC125, RC150, RC202, RC211, RC212, RC213, RC214, RC225, RC332, RC350, RC421, RC425, RC426, RC450, RC451, RC452, RC500, RC501, RC502, RC503, RC504, RC530, RC532, RC550, RC551, RC552, RC553, REIN, REMOVE_FAILED, REMOVE_SUCCESSFUL, RENAME_FAILED, REST, RETR, RMD, RNFR, RNTO, SITE, SMNT, STAT, STOR, STOU, STRU, SYST, TRANSFER_FAILED, TRANSFER_STOPPED, TRANSFER_SUCCESSFUL, TYPE, USER, W, WRONG_LOGIN_DATA |
| Constructor Summary | |
FtpConnection(java.lang.String host)
Create an instance with a given host |
|
FtpConnection(java.lang.String host,
int port,
java.lang.String initCWD)
Create an instance with a given host, port and initial remote working directory |
|
| Method Summary | |
void |
abort()
Try to abort the transfer. |
void |
abortTransfer()
Abort the last spawned transfer. |
void |
addConnectionListener(ConnectionListener l)
Add a ConnectionListener. |
void |
ascii()
Tell server we want ascii data connections. |
void |
binary()
Tell server we want binary data connections. |
boolean |
cdup()
Change to the parent of the current working directory. |
boolean |
chdir(java.lang.String p)
Parses directory and does a chdir(). |
boolean |
chdirNoRefresh(java.lang.String p)
Parses directory and does a chdir(), but does not send an update signal |
boolean |
chdirRaw(java.lang.String dirName)
Change directory unparsed. |
void |
disconnect()
Disconnect from the server. |
int |
download(java.lang.String file)
Download a file or directory, block until finished. |
int |
exists(java.lang.String file)
Checks wheter a file exists. |
void |
fireActionFinished(FtpConnection con)
Transfer is done |
void |
fireConnectionFailed(FtpConnection con,
java.lang.String why)
We are not logged in for some reason |
void |
fireConnectionInitialized(FtpConnection con)
Connection is there and user logged in |
void |
fireDirectoryUpdate(FtpConnection con)
Remote directory has changed. |
void |
fireProgressUpdate(java.lang.String file,
java.lang.String type,
int bytes)
Progress update. |
java.lang.String |
getCachedPWD()
Returns current remote directory (cached) |
ConnectionHandler |
getConnectionHandler()
Return the ConnectionHandler. |
DataConnection |
getDataConnection()
Return the DataConnection. |
java.io.InputStream |
getDownloadInputStream(java.lang.String file)
Get download InputStream. |
java.lang.String |
getHost()
Return the host used. |
FtpTransfer |
getLastInitiatedTransfer()
Get the last FtpTransfer object spawned. |
java.lang.String |
getLine(java.lang.String until)
Reads the response until line found or error. |
java.lang.String |
getLine(java.lang.String[] until)
Reads the response until line found or error. |
java.lang.String |
getLocalPath()
Return the local working directory |
java.lang.String |
getOsType()
Try to determine the os-type. |
java.lang.String |
getPassword()
Return the password. |
int[] |
getPermissions(java.lang.String file)
Sort the permissions an return an array. |
int |
getPort()
Get the port. |
java.lang.String |
getPWD()
Get the current remote directory. |
java.lang.String |
getTypeNow()
Returns the type used. |
java.lang.String |
getUsername()
Return the username. |
int |
handleDownload(java.lang.String file)
Download a file or directory. |
int |
handleUpload(java.lang.String file)
Upload a file or directory. |
int |
handleUpload(java.lang.String file,
java.lang.String realName)
Upload a file or directory. |
boolean |
isConnected()
Check if login() was successful. |
void |
list(java.lang.String outfile)
List remote directory. |
int |
login(java.lang.String username,
java.lang.String password)
Connect to the server an log in. |
boolean |
mkdir(java.lang.String dirName)
Create a directory with the given name. |
java.lang.String |
mode(java.lang.String code)
Set mode manually. |
void |
modeBlocked()
Unsupported at this time. |
void |
modeCompressed()
|
void |
modeStream()
Set mode to Stream. |
void |
noop()
Do nothing, but flush buffers |
void |
pause(int time)
Waits a specified amount of time |
int |
removeFileOrDir(java.lang.String file)
Remove a remote file or directory. |
boolean |
rename(java.lang.String from,
java.lang.String to)
Moves or renames remote file. |
void |
sendRawCommand(java.lang.String cmd)
Execute a remote command. |
void |
setConnectionHandler(ConnectionHandler h)
Set the ConnectionHandler. |
void |
setConnectionListeners(java.util.Vector l)
Add a Vector of ConnectionListeners. |
boolean |
setLocalPath(java.lang.String newPath)
Set the local working directory |
java.lang.String[] |
sortLs(java.lang.String file)
Sort the filenames of the current working dir an return an array. |
java.lang.String[] |
sortSize(java.lang.String file)
Sort the filesizes an return an array. |
java.lang.String |
system()
This command is used to find out the type of operating system at the server. |
boolean |
type(java.lang.String code)
Set type (L8,I,A for example). |
int |
upload(java.lang.String file)
Upload a file or directory, block until finished. |
int |
upload(java.lang.String file,
java.io.InputStream in)
Upload from an InputStream, block until finished. |
int |
upload(java.lang.String file,
java.lang.String realName)
Upload and a file or directory under a given name, block until finished. |
int |
upload(java.lang.String file,
java.lang.String realName,
java.io.InputStream in)
Upload and a file or directory under a given name, block until finished. |
| 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 DOWNLOAD
public static final java.lang.String UPLOAD
public static final java.lang.String ABOR
public boolean hasUploaded
public boolean work
public static final java.lang.String ASCII
public static final java.lang.String BINARY
public static final java.lang.String EBCDIC
public static final java.lang.String L8
public static final java.lang.String STREAM
public static final java.lang.String BLOCKED
public static final java.lang.String COMPRESSED
| Constructor Detail |
public FtpConnection(java.lang.String host)
host - The host to connect to
public FtpConnection(java.lang.String host,
int port,
java.lang.String initCWD)
host - The host to connect toport - The port used for the control connection, usually 21initCWD - The initial remote working directory| Method Detail |
public int login(java.lang.String username,
java.lang.String password)
username - The usernamepassword - The password
public java.lang.String[] sortSize(java.lang.String file)
sortSize in interface BasicConnectionfile - The file containing the raw server listing, usually Settings.ls_out
public int[] getPermissions(java.lang.String file)
getPermissions in interface BasicConnectionfile - The file containing the raw server listing, usually Settings.ls_out
public java.lang.String[] sortLs(java.lang.String file)
sortLs in interface BasicConnectionfile - The file containing the raw server listing, usually Settings.ls_out
public java.lang.String getOsType()
public int handleDownload(java.lang.String file)
handleDownload in interface BasicConnectionfile - The file to download
public int download(java.lang.String file)
download in interface BasicConnectionfile - The file to download
public java.io.InputStream getDownloadInputStream(java.lang.String file)
getDownloadInputStream in interface BasicConnectionfile - The file to download
public int handleUpload(java.lang.String file)
handleUpload in interface BasicConnectionfile - The file to upload
public int handleUpload(java.lang.String file,
java.lang.String realName)
file - The file to uploadrealName - The file to rename the uploaded file to
public int upload(java.lang.String file)
upload in interface BasicConnectionfile - The file to upload
public int upload(java.lang.String file,
java.lang.String realName)
file - The file to uploadrealName - The file to rename the uploaded file to
public int upload(java.lang.String file,
java.io.InputStream in)
upload in interface BasicConnectionfile - The file to uploadin - InputStream to read from
public int upload(java.lang.String file,
java.lang.String realName,
java.io.InputStream in)
file - The file to uploadrealName - The file to rename the uploaded file toin - InputStream to read from
public int removeFileOrDir(java.lang.String file)
removeFileOrDir in interface BasicConnectionfile - The file to remove
public void disconnect()
disconnect in interface BasicConnectionpublic void sendRawCommand(java.lang.String cmd)
sendRawCommand in interface BasicConnectioncmd - The raw command that is to be sent to the serverpublic java.lang.String getLine(java.lang.String until)
until - The String the response line hast to start with, 2 for succesful return codes for examplepublic java.lang.String getLine(java.lang.String[] until)
public boolean isConnected()
isConnected in interface BasicConnectionpublic java.lang.String getPWD()
getPWD in interface BasicConnectionpublic java.lang.String getCachedPWD()
public boolean chdirRaw(java.lang.String dirName)
dirName - The raw directory name
public boolean cdup()
cdup in interface BasicConnectionpublic boolean mkdir(java.lang.String dirName)
mkdir in interface BasicConnectiondirName - The name of the directory to create
public void list(java.lang.String outfile)
throws java.io.IOException
list in interface BasicConnectionoutfile - The file to save the output to, usually Settings.ls_out
java.io.IOExceptionpublic boolean chdir(java.lang.String p)
chdir in interface BasicConnectionpublic boolean chdirNoRefresh(java.lang.String p)
chdirNoRefresh in interface BasicConnectionpublic void pause(int time)
time - The time to sleep in millisecondspublic java.lang.String getLocalPath()
getLocalPath in interface BasicConnectionpublic boolean setLocalPath(java.lang.String newPath)
setLocalPath in interface BasicConnectionnewPath - The new local CWD
public int exists(java.lang.String file)
file - the name of the file
public boolean rename(java.lang.String from,
java.lang.String to)
from - remote file to move or rename.to - new file name.
true if completed successfully; false otherwise.public int getPort()
public void binary()
public void ascii()
public boolean type(java.lang.String code)
public java.lang.String getTypeNow()
public void noop()
public void abort()
public java.lang.String system()
public void modeStream()
public void modeBlocked()
public void modeCompressed()
public java.lang.String mode(java.lang.String code)
code - The mode code wanted, I, A, L8 for example
public java.lang.String getHost()
public java.lang.String getUsername()
public java.lang.String getPassword()
public DataConnection getDataConnection()
public void addConnectionListener(ConnectionListener l)
addConnectionListener in interface BasicConnectionl - A ConnectionListener objectpublic void setConnectionListeners(java.util.Vector l)
setConnectionListeners in interface BasicConnectionl - A Vector containig ConnectionListener objectspublic void fireDirectoryUpdate(FtpConnection con)
con - The FtpConnection calling the event
public void fireProgressUpdate(java.lang.String file,
java.lang.String type,
int bytes)
file - The file transferredtype - the type of event, DataConnection.GETDIR for examplebytes - The number of bytes transferred so farpublic void fireConnectionInitialized(FtpConnection con)
con - The FtpConnection calling the event
public void fireConnectionFailed(FtpConnection con,
java.lang.String why)
con - The FtpConnection calling the eventwhy - The login() response codepublic void fireActionFinished(FtpConnection con)
con - The FtpConnection calling the eventpublic ConnectionHandler getConnectionHandler()
public void setConnectionHandler(ConnectionHandler h)
h - The connection handler that is to be used by this connectionpublic FtpTransfer getLastInitiatedTransfer()
public void abortTransfer()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||