public class FtpSession extends java.lang.Object implements FtpSupportIntf
Constructor and Description |
---|
FtpSession(LoggerIfc l)
Creats an FtpSession object.
|
FtpSession(java.lang.String host,
int port,
java.lang.String login,
java.lang.String password,
LoggerIfc l)
Creates an FtpSession object with the given host, login and
password.
|
FtpSession(java.lang.String host,
int port,
java.lang.String login,
java.lang.String password,
LoggerIfc l,
int timerDelay)
Creates an FtpSession object with the given host, login and
password and timer delay..
|
FtpSession(java.lang.String host,
java.lang.String login,
java.lang.String password,
LoggerIfc l)
Creates an FtpSession object with the given host, login and
password.
|
FtpSession(java.lang.String host,
java.lang.String login,
java.lang.String password,
LoggerIfc l,
int timerDelay) |
Modifier and Type | Method and Description |
---|---|
boolean |
cd(java.lang.String remotePath)
Changes the current working directory.
|
boolean |
delete(java.lang.String fileName)
Remove a file from the remote host.
|
void |
disconnect()
Disconnects from the remote server
|
void |
enableLocalActiveMode()
Enables local active mode for transfers
|
void |
enableLocalPassiveMode()
Enables local passive mode for transfers
|
boolean |
get(java.lang.String localFile,
java.lang.String remoteFile)
Copy the remote file to the local file.
|
java.lang.String |
getHost()
Returns the remote host
|
java.lang.String |
getLogin()
Returns the login name
|
java.lang.String |
getPassword()
Returns the login password
|
int |
getPort() |
long |
getTimeout()
Returns the timeout for FTP operations
|
java.util.Date |
getTimestamp(java.lang.String remoteFile)
gets the timestamp of the remote file
|
java.lang.String[] |
listDirectories()
lists the directories in the current working directory
|
java.lang.String[] |
listDirectories(java.lang.String remotePath)
lists the directories of the remote path
|
java.lang.String[] |
listFiles()
Returns the list of files in the current remote directory.
|
java.lang.String[] |
listFiles(java.lang.String remotePath)
Returns the list of files in the given remote directory.
|
FtpItem[] |
listItems()
Returns the list of files in the current remote directory.
|
FtpItem[] |
listItems(java.lang.String remotePath)
Returns the list of files in the given remote directory.
|
boolean |
login()
Logs into the remote host, using the internally set
ip address, login name and password.
|
boolean |
login(java.lang.String ip,
java.lang.String login,
java.lang.String password)
Logs into the remote host, using the given ip address, login name
and password.
|
boolean |
logout()
Logs out from the remote server
|
boolean |
put(java.lang.String localFile,
java.lang.String remoteFile)
Copy the local file to the remote file.
|
java.lang.String |
pwd()
Returns the present working directory.
|
boolean |
rename(java.lang.String from,
java.lang.String to)
renames files on a remote server
|
void |
setAsciiFileType()
Sets the transfer file type to ASCII
|
void |
setBinaryFileType()
Sets the transfer file type to BINARY
|
void |
setHost(java.lang.String host)
Sets the remote host.
|
void |
setLogin(java.lang.String login)
Sets the login name.
|
void |
setPassword(java.lang.String pw)
Sets the login password
|
void |
setPort(int port) |
void |
setTimeout(int timeout)
Sets the timeout for FTP operations
|
public FtpSession(LoggerIfc l)
logger
- event loggerpublic FtpSession(java.lang.String host, java.lang.String login, java.lang.String password, LoggerIfc l)
host
- remote host (ip or hostname)login
- login namepassword
- login passwordlogger
- event loggerpublic FtpSession(java.lang.String host, java.lang.String login, java.lang.String password, LoggerIfc l, int timerDelay)
public FtpSession(java.lang.String host, int port, java.lang.String login, java.lang.String password, LoggerIfc l)
host
- remote host (ip or hostname)port
- Ftp port number, default is 21login
- login namepassword
- login passwordlogger
- event loggerpublic FtpSession(java.lang.String host, int port, java.lang.String login, java.lang.String password, LoggerIfc l, int timerDelay)
host
- remote host (ip or hostname)port
- Ftp port number, default is 21login
- login namepassword
- login passwordl
- logger interface of the nodetimerDelay
- the timeout value for ftp connection,transfer.public void setHost(java.lang.String host)
host
- remote host, as an ip address or namepublic void setPort(int port)
public void setLogin(java.lang.String login)
login
- login namepublic void setPassword(java.lang.String pw)
pw
- login passwordpublic void setBinaryFileType()
setBinaryFileType
in interface FtpSupportIntf
public void setAsciiFileType()
setAsciiFileType
in interface FtpSupportIntf
public void enableLocalActiveMode()
public void enableLocalPassiveMode()
public void setTimeout(int timeout)
timeout
- - timeout interval in millisecondspublic java.lang.String getHost()
getHost
in interface FtpSupportIntf
public int getPort()
public java.lang.String getLogin()
getLogin
in interface FtpSupportIntf
public long getTimeout()
public java.lang.String getPassword()
getPassword
in interface FtpSupportIntf
public boolean login() throws java.io.IOException
java.io.IOException
public boolean login(java.lang.String ip, java.lang.String login, java.lang.String password) throws java.io.IOException
login
in interface FtpSupportIntf
ip
- remote ip addresslogin
- login namepassword
- login password
java.io.IOException
public boolean logout() throws java.io.IOException
logout
in interface FtpSupportIntf
java.io.IOException
public void disconnect() throws java.io.IOException
disconnect
in interface FtpSupportIntf
java.io.IOException
public boolean get(java.lang.String localFile, java.lang.String remoteFile) throws java.io.IOException
get
in interface FtpSupportIntf
localFile
- Local file name.remoteFile
- Remote file name.
java.io.IOException
public boolean put(java.lang.String localFile, java.lang.String remoteFile) throws java.io.IOException
put
in interface FtpSupportIntf
localFile
- Local file name.remoteFile
- Remote file name.
java.io.IOException
public boolean delete(java.lang.String fileName) throws java.io.IOException
delete
in interface FtpSupportIntf
fileName
- remote file pathnamejava.io.IOException
public java.lang.String pwd() throws java.io.IOException
pwd
in interface FtpSupportIntf
java.io.IOException
public boolean cd(java.lang.String remotePath) throws java.io.IOException
cd
in interface FtpSupportIntf
remotePath
- new remote directoryjava.io.IOException
public java.lang.String[] listFiles(java.lang.String remotePath) throws java.io.IOException
listFiles
in interface FtpSupportIntf
remotePath
- remote directory to listjava.io.IOException
public java.lang.String[] listFiles() throws java.io.IOException
listFiles
in interface FtpSupportIntf
java.io.IOException
public FtpItem[] listItems(java.lang.String remotePath) throws java.io.IOException
remotePath
- remote directory to listjava.io.IOException
public FtpItem[] listItems() throws java.io.IOException
java.io.IOException
public java.lang.String[] listDirectories() throws java.io.IOException
java.io.IOException
public java.lang.String[] listDirectories(java.lang.String remotePath) throws java.io.IOException
listDirectories
in interface FtpSupportIntf
remotePath
- remote directory to listjava.io.IOException
public java.util.Date getTimestamp(java.lang.String remoteFile) throws java.io.IOException
getTimestamp
in interface FtpSupportIntf
remoteFile
- remote path for which to get timestampjava.io.IOException
public boolean rename(java.lang.String from, java.lang.String to) throws java.io.IOException
rename
in interface FtpSupportIntf
java.io.IOException