com.sshtools.j2ssh

Class ScpClient


public final class ScpClient
extends java.lang.Object

Implements a Secure Copy (SCP) client. This may be useful when the server does not support SFTP.
Version:
$Revision: 1.18 $
Author:
Lee David Painter
Since:
0.2.0

Constructor Summary

ScpClient(File cwd, SshClient ssh, boolean verbose, ChannelEventListener eventListener)
Creates an SCP client.
ScpClient(SshClient ssh, boolean verbose, ChannelEventListener eventListener)
Creates an SCP client.

Method Summary

InputStream
get(String remoteFile)
Gets a remote file as an java.io.InputStream.
void
get(String localFile, String remoteFile, boolean recursive)
Downloads a remote file onto the local computer.
void
get(String localFile, String[] remoteFiles, boolean recursive)
Downloads an array of remote files to the local computer.
void
put(InputStream in, long length, String localFile, String remoteFile)
Uploads a java.io.InputStream to a remove server as file.
void
put(String localFile, String remoteFile, boolean recursive)
Uploads a local file onto the remote server.
void
put(String[] localFiles, String remoteFile, boolean recursive)
Uploads an array of local files onto the remote server.

Constructor Details

ScpClient

public ScpClient(File cwd,
                 SshClient ssh,
                 boolean verbose,
                 ChannelEventListener eventListener)
Creates an SCP client.
Parameters:
cwd - The current local directory
ssh - A connected SshClient
verbose - Output verbose detail
eventListener -
Since:
0.2.0

ScpClient

public ScpClient(SshClient ssh,
                 boolean verbose,
                 ChannelEventListener eventListener)
Creates an SCP client. CWD (Current working directory) will be the CWD of the process that started this JVM.
Parameters:
ssh - A connected SshClient
verbose - Output verbose detail
eventListener -
Since:
0.2.0

Method Details

get

public InputStream get(String remoteFile)
            throws IOException
Gets a remote file as an java.io.InputStream.
Parameters:
remoteFile - remote file name
Returns:
stream

get

public void get(String localFile,
                String remoteFile,
                boolean recursive)
            throws IOException
Downloads a remote file onto the local computer.
Parameters:
localFile - The path to place the file
remoteFile - The path of the file on the remote server
recursive - recursivly copy the contents of a directory
Since:
0.2.0

get

public void get(String localFile,
                String[] remoteFiles,
                boolean recursive)
            throws IOException
Downloads an array of remote files to the local computer.
Parameters:
localFile - The local path to place the files
remoteFiles - The path of the remote files
recursive - recursivly copy the contents of a directory
Since:
0.2.0

put

public void put(InputStream in,
                long length,
                String localFile,
                String remoteFile)
            throws IOException
Uploads a java.io.InputStream to a remove server as file. You must supply the correct number of bytes that will be written.
Parameters:
in - stream providing file
length - number of bytes that will be written
localFile - local file name
remoteFile - remote file name

put

public void put(String localFile,
                String remoteFile,
                boolean recursive)
            throws IOException
Uploads a local file onto the remote server.
Parameters:
localFile - The path to the local file relative to the local current directory; may be a file or directory
remoteFile - The path on the remote server, may be a file or directory
recursive - Copy the contents of a directory recursivly
Since:
0.2.0

put

public void put(String[] localFiles,
                String remoteFile,
                boolean recursive)
            throws IOException
Uploads an array of local files onto the remote server.
Parameters:
localFiles - an array of local files; may be files or directories
remoteFile - the path on the remote server, may be a file or directory1
recursive - Copy the contents of directorys recursivly
Since:
0.2.0

Copyright © 2002-2003 Lee David Painter & Contributors. All Rights Reserved.