|
Secure FTP Factory | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.jscape.inet.scp.Scp
Implements the basic functionality of an SCP (Secure Copy) client over SSH2 protocol.
Example Usage:
// create new SshParamters instance SshParameters params = new SshParameters(hostname,username,password);// create new Scp instance Scp scp = new Scp(params);
// register event listener scp.addListener(this);
// establish connection scp.connect();
// upload file to remote directory scp.upload(new File("c:/tmp/file.txt"),"/home/jsmith/");
// disconnect scp.disconnect();
| Constructor Summary | |
Scp(SshParameters sshParameters)
Creates a new client instance. |
|
Scp(SshParameters sshParameters,
com.jscape.inet.ssh.SshConfiguration configuration)
Creates a new client instance. |
|
| Method Summary | |
void |
addListener(ScpEventListener listener)
Adds an event listener. |
void |
connect()
Connects to the server. |
void |
disconnect()
Disconnects from the server. |
void |
download(java.io.OutputStream out,
java.lang.String remoteDir,
java.lang.String remoteFile)
Downloads file from SSH server and writes to specified output stream. |
java.io.File |
download(java.lang.String remoteDir,
java.lang.String remoteFile)
Downloads the file from SSH server. |
void |
downloadDir(java.lang.String remoteDir,
java.lang.String name)
Downloads remote directory and contents recursively from SSH server. |
com.jscape.inet.ssh.SshConfiguration |
getConfiguration()
Returns current SSH configuraton. |
boolean |
getDebug()
Returns current debug status. |
java.io.PrintStream |
getDebugStream()
Gets PrintStream used in reporting debugging statements. |
int |
getDownloadBlockSize()
Returns download block size in bytes. |
java.lang.String |
getHost()
Returns server host name/IP. |
SshHostKeys |
getHostKeys()
Returns SSH host keys for further use. |
java.io.File |
getLocalDir()
Returns current local directory. |
SshParameters |
getParameters()
Returns current SSH parameters. |
int |
getPort()
Returns server port. |
boolean |
getPreserveTime()
Checks if preserve time flag is set. |
int |
getUploadBlockSize()
Returns upload block size in bytes. |
void |
interrupt()
Interrupts current transfer process. |
boolean |
isConnected()
Checks if client is connected. |
void |
mdownload(java.lang.String remoteDir,
java.util.Enumeration fileNames)
Downloads specified files in current working remote directory from SSH server to local directory. |
void |
mdownload(java.lang.String remoteDir,
java.util.Iterator fileNames)
Downloads specified files in current working remote directory from SSH server to local directory. |
void |
mdownload(java.lang.String remoteDir,
java.lang.String filter)
Downloads multiple files matching filter from SSH server's directory. |
void |
mdownload(java.lang.String remoteDir,
java.lang.String[] fileNames)
Downloads specified files in current working remote directory from SSH server to local directory. |
void |
mupload(java.lang.String remoteDir,
java.util.Enumeration fileNames)
Uploads multiple files to SSH server. |
void |
mupload(java.lang.String remoteDir,
java.util.Iterator fileNames)
Uploads multiple files to SSH server. |
void |
mupload(java.lang.String remoteDir,
java.lang.String filter)
Uploads multiple files matching regular expression to SSH server's current directory. |
void |
mupload(java.lang.String remoteDir,
java.lang.String[] fileNames)
Uploads multiple files to SSH server. |
void |
removeListener(ScpEventListener listener)
Removes listener. |
void |
setDebug(boolean value)
Sets debug status. |
void |
setDebugStream(java.io.PrintStream debugStream)
Sets PrintStream used in reporting debugging statements. |
void |
setDownloadBlockSize(int downloadBlockSize)
Sets download block size. |
void |
setLocalDir(java.io.File localDir)
Sets current local directory. |
void |
setPreserveTime(boolean preserveTime)
Sets preserver time flag. |
void |
setReceiveBufferSize(int receiveBufferSize)
Sets the receive buffer size option of the scp connection. |
void |
setSendBufferSize(int sendBufferSize)
Sets the send buffer size option of the scp connection. |
void |
setUploadBlockSize(int uploadBlockSize)
Sets upload block size. |
void |
upload(byte[] data,
java.lang.String remoteDir,
java.lang.String remoteFile)
Uploads file to SSH server where contents of file is not on disk but in memory. |
void |
upload(java.io.File file,
java.lang.String remoteDir)
Uploads file to SSH server. |
void |
upload(java.io.File file,
java.lang.String remoteDir,
java.lang.String remoteFile)
Uploads file to SSH server. |
void |
upload(java.io.InputStream in,
java.lang.String remoteDir,
java.lang.String remoteFile)
Uploads file to SSH server. |
void |
upload(java.lang.String remoteDir,
java.lang.String filename)
Uploads file to SSH server. |
void |
upload(java.lang.String localFile,
java.lang.String remoteDir,
java.lang.String remoteFile)
Uploads file to SSH server. |
void |
uploadDir(java.io.File dir,
java.lang.String remoteDir)
Uploads the specified directory. |
void |
uploadDir(java.io.File dir,
java.lang.String remoteDir,
java.lang.String remoteName)
Uploads the specified directory. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Scp(SshParameters sshParameters,
com.jscape.inet.ssh.SshConfiguration configuration)
sshParameters - ssh connection parametersconfiguration - ssh configuration parameterspublic Scp(SshParameters sshParameters)
sshParameters - ssh connection parameters| Method Detail |
public SshParameters getParameters()
public com.jscape.inet.ssh.SshConfiguration getConfiguration()
public java.lang.String getHost()
public int getPort()
public java.io.File getLocalDir()
public void setLocalDir(java.io.File localDir)
localDir - local directorypublic int getUploadBlockSize()
public void setUploadBlockSize(int uploadBlockSize)
uploadBlockSize - upload block size in bytespublic int getDownloadBlockSize()
public void setDownloadBlockSize(int downloadBlockSize)
downloadBlockSize - download block size in bytespublic boolean getPreserveTime()
public void setPreserveTime(boolean preserveTime)
preserveTime - preserve timepublic boolean getDebug()
true if debug is on;
false otherwisepublic void setDebug(boolean value)
value - if true debug output will bw turned onpublic void setDebugStream(java.io.PrintStream debugStream)
debugStream - the PrintStream to send debug statements toPrintStreampublic java.io.PrintStream getDebugStream()
PrintStreampublic void addListener(ScpEventListener listener)
listener - event listenerpublic void removeListener(ScpEventListener listener)
listener - target listenerpublic SshHostKeys getHostKeys()
null if keys are not available
public void connect()
throws ScpException
ScpException - if an I/O error occurspublic void disconnect()
public boolean isConnected()
true if client is connected; false otherwisepublic void interrupt()
public void setSendBufferSize(int sendBufferSize)
sendBufferSize - Send buffer size.public void setReceiveBufferSize(int receiveBufferSize)
receiveBufferSize - Receive buffer size.
public void download(java.io.OutputStream out,
java.lang.String remoteDir,
java.lang.String remoteFile)
throws java.io.IOException
out - the OutputStream to writing file toremoteDir - remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryremoteFile - the remote file to download
java.io.IOException - if an I/O, SSH or Scp error occurs.
public java.io.File download(java.lang.String remoteDir,
java.lang.String remoteFile)
throws java.io.IOException
remoteDir - remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryremoteFile - the remote file to download
java.io.IOException - if an I/O or SSH error occurs.
public void mdownload(java.lang.String remoteDir,
java.util.Enumeration fileNames)
throws java.io.IOException
remoteDir - remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryfileNames - filenames of files to download
java.io.IOException - if an I/O or SSH error occurs.downloadDir(String, String)
public void mdownload(java.lang.String remoteDir,
java.util.Iterator fileNames)
throws java.io.IOException
remoteDir - remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryfileNames - filenames of files to download
java.io.IOException - if an I/O or SSH error occurs.downloadDir(String, String)
public void mdownload(java.lang.String remoteDir,
java.lang.String[] fileNames)
throws java.io.IOException
remoteDir - remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryfileNames - filenames of files to download
java.io.IOException - if an I/O or SSH error occurs.downloadDir(String, String)
public void mdownload(java.lang.String remoteDir,
java.lang.String filter)
throws java.io.IOException
remoteDir - remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryfilter - the filter to use
java.io.IOException - if an I/O or SSH error occurs.downloadDir(java.lang.String, java.lang.String)
public void downloadDir(java.lang.String remoteDir,
java.lang.String name)
throws java.io.IOException
remoteDir - remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryname - the directory to download
java.io.IOException - if an I/O or SSH error occurs.
public void upload(byte[] data,
java.lang.String remoteDir,
java.lang.String remoteFile)
throws java.io.IOException
data - the raw contents of the file to uploadremoteDir - remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryremoteFile - the filename to store file as on SSH server
java.io.IOException - if an I/O or SSH error occurs.
public void upload(java.io.InputStream in,
java.lang.String remoteDir,
java.lang.String remoteFile)
throws java.io.IOException
in - the input stream to read fromremoteDir - remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryremoteFile - the remote file name relative to current remote directory
java.io.IOException - if an I/O or SSH error occurs
public void upload(java.io.File file,
java.lang.String remoteDir)
throws java.io.IOException
file - file to uploadremoteDir - remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directory
java.io.IOException - if an I/O or SSH error occurs
public void upload(java.io.File file,
java.lang.String remoteDir,
java.lang.String remoteFile)
throws java.io.IOException
file - file to uploadremoteDir - remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryremoteFile - the remote file name relative to current remote directory
java.io.IOException - if an I/O or SSH error occurs
public void upload(java.lang.String remoteDir,
java.lang.String filename)
throws java.io.IOException
remoteDir - remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryfilename - file name to upload
java.io.IOException - if an I/O or SSH error occurs
public void upload(java.lang.String localFile,
java.lang.String remoteDir,
java.lang.String remoteFile)
throws java.io.IOException
remoteDir - remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directorylocalFile - local file name relative to local directoryremoteFile - the remote file name relative to current remote directory
java.io.IOException - if an I/O or SSH error occurssetLocalDir(java.io.File)
public void mupload(java.lang.String remoteDir,
java.util.Enumeration fileNames)
throws java.io.IOException
remoteDir - remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryfileNames - filenames of files to upload
java.io.IOException - if an I/O or SSH error occurs.
public void mupload(java.lang.String remoteDir,
java.util.Iterator fileNames)
throws java.io.IOException
remoteDir - remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryfileNames - filenames of files to upload
java.io.IOException - if an I/O or SSH error occurs.
public void mupload(java.lang.String remoteDir,
java.lang.String[] fileNames)
throws java.io.IOException
remoteDir - remote directory path with ending path separator (i.e "/user/home/") or empty line for current directoryfileNames - filenames of files to upload
java.io.IOException - if an I/O or SSH error occurs.
public void mupload(java.lang.String remoteDir,
java.lang.String filter)
throws java.io.IOException
remoteDir - remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryfilter - the filter to use
java.io.IOException - if an I/O or SSH error occurs.
public void uploadDir(java.io.File dir,
java.lang.String remoteDir,
java.lang.String remoteName)
throws java.io.IOException
dir - directory to uploadremoteDir - remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directoryremoteName - the remote directory name relative to current remote directory
java.io.IOException - if an I/O or SSH error occurs
public void uploadDir(java.io.File dir,
java.lang.String remoteDir)
throws java.io.IOException
remoteDir - remote directory path with ending path separator (i.e "/user/home/")
or empty line for current directorydir - directory to upload
java.io.IOException - if an I/O or SSH error occurs
|
Secure FTP Factory | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||