Package com.nt.udc.ndk.util
Class SftpSession
java.lang.Object
com.nt.udc.ndk.util.SftpSession
- All Implemented Interfaces:
FtpSupportIntf
Network Mediation
User: jwu
Date: Aug 8, 2003
Time: 9:50:24 AM
MetaSolv Software Inc.
-
Constructor Summary
ConstructorsConstructorDescriptionSftpSession(LoggerIfc logger) Creats an FtpSession object.SftpSession(String host, int port, String login, String password, String hostsFile, LoggerIfc logger) Creates an FtpSession object with the given host, login and password.SftpSession(String host, String login, String password, LoggerIfc logger) Creates an FtpSession object with the given host, login and password. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChanges the current working directory.booleanRemove a file from the remote host.voidDisconnects from the remote serverbooleanCopy the remote file to the local file.getHost()Returns the remote hostgetLogin()Returns the login nameReturns the login passwordintgetPort()longReturns the timeout for FTP operationsgetTimestamp(String remotePath) Returns the timestamp of the given remote path.String[]listDirectories(String remotePath) Returns the list of directories in the given remote directory.String[]Returns the list of files in the current remote directory.String[]Returns the list of files in the given remote directory.booleanlogin()Logs into the remote host, using the internally set ip address, login name and password.booleanLogs into the remote host, using the given ip address, login name and password.booleanlogout()Logs out from the remote serverbooleanCopy the local file to the remote file.pwd()Returns the present working directory.booleanrenames files on a remote servervoidSets the transfer file type to ASCIIvoidSets the transfer file type to BINARYvoidSets the remote host.voidSets the login name.voidsetPassword(String pw) Sets the login passwordvoidsetPort(int port) voidsetTimeout(long timeout) Sets the timeout for FTP operations
-
Constructor Details
-
SftpSession
Creats an FtpSession object.- Parameters:
logger- event logger
-
SftpSession
Creates an FtpSession object with the given host, login and password.- Parameters:
host- remote host (ip or hostname)login- login namepassword- login passwordlogger- event logger
-
SftpSession
public SftpSession(String host, int port, String login, String password, String hostsFile, LoggerIfc logger) Creates an FtpSession object with the given host, login and password.- Parameters:
host- remote host (ip or hostname)port- Ftp port number, default is 22 for SFTPlogin- login namepassword- login passwordhostsFile- Hosts filelogger- event logger
-
-
Method Details
-
setBinaryFileType
public void setBinaryFileType()Sets the transfer file type to BINARY- Specified by:
setBinaryFileTypein interfaceFtpSupportIntf
-
setAsciiFileType
public void setAsciiFileType()Sets the transfer file type to ASCII- Specified by:
setAsciiFileTypein interfaceFtpSupportIntf
-
setHost
Sets the remote host.- Parameters:
host- remote host, as an ip address or name
-
setPort
public void setPort(int port) -
setLogin
Sets the login name.- Parameters:
login- login name
-
setPassword
Sets the login password- Parameters:
pw- login password
-
setTimeout
public void setTimeout(long timeout) Sets the timeout for FTP operations- Parameters:
timeout- - timeout interval in milliseconds
-
getHost
Returns the remote host- Specified by:
getHostin interfaceFtpSupportIntf- Returns:
- remote host name
-
getPort
public int getPort() -
getLogin
Returns the login name- Specified by:
getLoginin interfaceFtpSupportIntf- Returns:
- login name
-
getTimeout
public long getTimeout()Returns the timeout for FTP operations- Returns:
- timeout interval in milliseconds
-
getPassword
Returns the login password- Specified by:
getPasswordin interfaceFtpSupportIntf- Returns:
- login password
-
login
Logs into the remote host, using the internally set ip address, login name and password.- Returns:
- true, if login is successful. false, otherwise.
- Throws:
IOException
-
login
Logs into the remote host, using the given ip address, login name and password.- Specified by:
loginin interfaceFtpSupportIntf- Parameters:
ip- remote ip addresslogin- login namepassword- login password- Returns:
- true, if login is successful. false, otherwise.
- Throws:
IOException
-
logout
Logs out from the remote server- Specified by:
logoutin interfaceFtpSupportIntf- Throws:
IOException
-
disconnect
Disconnects from the remote server- Specified by:
disconnectin interfaceFtpSupportIntf- Throws:
IOException
-
get
Copy the remote file to the local file. One must set the appropriate file type before the get; the default is binary mode.- Specified by:
getin interfaceFtpSupportIntf- Parameters:
localFile- Local file name.remoteFile- Remote file name.- Returns:
- true, if get was successful.
- Throws:
IOException
-
put
Copy the local file to the remote file. One must set the appropriate file type before the get; the default is binary mode.- Specified by:
putin interfaceFtpSupportIntf- Parameters:
localFile- Local file name.remoteFile- Remote file name.- Returns:
- true, if get was successful.
- Throws:
IOException
-
delete
Remove a file from the remote host.- Specified by:
deletein interfaceFtpSupportIntf- Parameters:
fileName- remote file pathname- Returns:
- true, if delete was successful
- Throws:
IOException
-
pwd
Returns the present working directory.- Specified by:
pwdin interfaceFtpSupportIntf- Returns:
- present working directory
- Throws:
IOException
-
cd
Changes the current working directory.- Specified by:
cdin interfaceFtpSupportIntf- Parameters:
remotePath- new remote directory- Returns:
- present working directory
- Throws:
IOException
-
listFiles
Returns the list of files in the given remote directory.- Specified by:
listFilesin interfaceFtpSupportIntf- Parameters:
remotePath- remote directory to list- Returns:
- list of files (null if no files found)
- Throws:
IOException
-
listFiles
Returns the list of files in the current remote directory.- Specified by:
listFilesin interfaceFtpSupportIntf- Returns:
- list of files (null if no files found)
- Throws:
IOException
-
listDirectories
Returns the list of directories in the given remote directory.- Specified by:
listDirectoriesin interfaceFtpSupportIntf- Parameters:
remotePath- remote directory to list- Returns:
- list of directories
- Throws:
IOException
-
getTimestamp
Returns the timestamp of the given remote path.- Specified by:
getTimestampin interfaceFtpSupportIntf- Parameters:
remotePath- remote path for which to get timestamp- Returns:
- timestamp of the remote path
- Throws:
IOException
-
rename
renames files on a remote server- Specified by:
renamein interfaceFtpSupportIntf- Throws:
IOException
-