examples
public class SCPExample2 extends java.lang.Object
See the main method for an example on how to do a file
transfer, and also how to expand glob expressions.
The copyFilesWithSSH1 method will copy files using the SSH1 protocol.
The copyFilesWithSSH2 method will copy files using the SSH2 protocol.
The doGlob method will expand glob expressions.
SSHSCP1,
SFTPCopyFile| Constructor and Description |
|---|
SCPExample2() |
| Modifier and Type | Method and Description |
|---|---|
static void |
copyFilesWithSSH1(java.lang.String server,
int port,
java.lang.String user,
java.lang.String privatekeyfile,
java.lang.String privatekeypassword,
java.lang.String[] files,
java.lang.String destination,
boolean toremote)
This copies files using an SSH1 connection.
|
static void |
copyFilesWithSSH2(java.lang.String server,
int port,
java.lang.String user,
java.lang.String privatekeyfile,
java.lang.String privatekeypassword,
java.lang.String[] files,
java.lang.String destination,
boolean toremote)
This copies files using an SSH2 connection.
|
static void |
main(java.lang.String[] argv)
Run the application
|
public static void copyFilesWithSSH1(java.lang.String server,
int port,
java.lang.String user,
java.lang.String privatekeyfile,
java.lang.String privatekeypassword,
java.lang.String[] files,
java.lang.String destination,
boolean toremote)
throws java.io.IOException,
java.net.UnknownHostException
server - server nameport - server portuser - user nameprivatekeyfile - the private key file, if null we will try to find the OpenSSH private key fileprivatekeypassword - the password for the private key file, null if none neededfiles - an array of files that should be transferreddestination - the destination file or directorytoremote - true if files should be copied to the remote server, otherwise falsejava.io.IOExceptionjava.net.UnknownHostExceptionpublic static void copyFilesWithSSH2(java.lang.String server,
int port,
java.lang.String user,
java.lang.String privatekeyfile,
java.lang.String privatekeypassword,
java.lang.String[] files,
java.lang.String destination,
boolean toremote)
throws java.io.IOException,
java.net.UnknownHostException,
SSH2Exception
server - server nameport - server portuser - user nameprivatekeyfile - the private key file, if null we will try to find the OpenSSH private key fileprivatekeypassword - the password for the private key file, null if none neededfiles - an array of files that should be transferreddestination - the destination file or directorytoremote - true if files should be copied to the remote server, otherwise falsejava.io.IOExceptionjava.net.UnknownHostExceptionSSH2Exceptionpublic static void main(java.lang.String[] argv)