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 TypeMethodDescriptionboolean
Changes the current working directory.boolean
Remove a file from the remote host.void
Disconnects from the remote serverboolean
Copy the remote file to the local file.getHost()
Returns the remote hostgetLogin()
Returns the login nameReturns the login passwordint
getPort()
long
Returns 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.boolean
login()
Logs into the remote host, using the internally set ip address, login name and password.boolean
Logs into the remote host, using the given ip address, login name and password.boolean
logout()
Logs out from the remote serverboolean
Copy the local file to the remote file.pwd()
Returns the present working directory.boolean
renames files on a remote servervoid
Sets the transfer file type to ASCIIvoid
Sets the transfer file type to BINARYvoid
Sets the remote host.void
Sets the login name.void
setPassword
(String pw) Sets the login passwordvoid
setPort
(int port) void
setTimeout
(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:
setBinaryFileType
in interfaceFtpSupportIntf
-
setAsciiFileType
public void setAsciiFileType()Sets the transfer file type to ASCII- Specified by:
setAsciiFileType
in 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:
getHost
in interfaceFtpSupportIntf
- Returns:
- remote host name
-
getPort
public int getPort() -
getLogin
Returns the login name- Specified by:
getLogin
in 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:
getPassword
in 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:
login
in 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:
logout
in interfaceFtpSupportIntf
- Throws:
IOException
-
disconnect
Disconnects from the remote server- Specified by:
disconnect
in 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:
get
in 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:
put
in 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:
delete
in interfaceFtpSupportIntf
- Parameters:
fileName
- remote file pathname- Returns:
- true, if delete was successful
- Throws:
IOException
-
pwd
Returns the present working directory.- Specified by:
pwd
in interfaceFtpSupportIntf
- Returns:
- present working directory
- Throws:
IOException
-
cd
Changes the current working directory.- Specified by:
cd
in 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:
listFiles
in 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:
listFiles
in 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:
listDirectories
in interfaceFtpSupportIntf
- Parameters:
remotePath
- remote directory to list- Returns:
- list of directories
- Throws:
IOException
-
getTimestamp
Returns the timestamp of the given remote path.- Specified by:
getTimestamp
in 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:
rename
in interfaceFtpSupportIntf
- Throws:
IOException
-