public class Scp
extends java.lang.Object
It is based on the SCPClient from the ganymed ssh library from Christian Plattner, released under a BSD style license.
To minimize the dependency to the ssh library and because we needed some additional functionality, we decided to copy'n'paste the single class rather than to inherit or delegate it somehow.
Nevertheless credit should go to the original author.
Modifier and Type | Class and Description |
---|---|
class |
Scp.FileInfo |
Constructor and Description |
---|
Scp(com.jcraft.jsch.Session session) |
Modifier and Type | Method and Description |
---|---|
void |
get(java.lang.String remoteFile,
java.io.OutputStream localTarget)
Download a file from the remote server into an OutputStream
|
void |
get(java.lang.String remoteFile,
java.lang.String localTarget)
Download a file from the remote server to a local file.
|
Scp.FileInfo |
getFileinfo(java.lang.String remoteFile)
Initiates an SCP sequence but stops after getting fileinformation header
|
void |
put(java.lang.String localFile,
java.lang.String remoteTargetDir,
java.lang.String remoteTargetName,
java.lang.String mode)
Copy a local file to a remote site, uses the specified mode when creating the file on the
remote side.
|
public void put(java.lang.String localFile, java.lang.String remoteTargetDir, java.lang.String remoteTargetName, java.lang.String mode) throws java.io.IOException, RemoteScpException
localFile
- Path and name of local file. Must be absolute.remoteTargetDir
- Remote target directory where the file has to end up (optional)remoteTargetName
- file name to use on the target systemmode
- a four digit string (e.g., 0644, see "man chmod", "man open")java.io.IOException
- in case of network problemsRemoteScpException
- in case of problems on the target system (connection ok)public void get(java.lang.String remoteFile, java.lang.String localTarget) throws java.io.IOException, RemoteScpException
remoteFile
- Path and name of the remote file.localTarget
- Local file where to store the data. Must be absolute.java.io.IOException
- in case of network problemsRemoteScpException
- in case of problems on the target system (connection ok)public void get(java.lang.String remoteFile, java.io.OutputStream localTarget) throws java.io.IOException, RemoteScpException
remoteFile
- Path and name of the remote file.localTarget
- OutputStream to store the data.java.io.IOException
- in case of network problemsRemoteScpException
- in case of problems on the target system (connection ok)public Scp.FileInfo getFileinfo(java.lang.String remoteFile) throws java.io.IOException, RemoteScpException
remoteFile
- to get information forjava.io.IOException
- in case of network problemsRemoteScpException
- in case of problems on the target system (connection ok)