ch.ethz.ssh2
Class SCPClient

java.lang.Object
  extended by ch.ethz.ssh2.SCPClient

public class SCPClient
extends Object

A very basic SCPClient that can be used to copy files from/to the SSH-2 server. On the server side, the "scp" program must be in the PATH.

This scp client is thread safe - you can download (and upload) different sets of files concurrently without any troubles. The SCPClient is actually mapping every request to a distinct Session.

Version:
$Id$
Author:
Christian Plattner, plattner@inf.ethz.ch

Nested Class Summary
 class SCPClient.LenNamePair
           
 
Constructor Summary
SCPClient(Connection conn)
           
 
Method Summary
 SCPInputStream get(String remoteFile)
          The session for opened for this SCP transfer must be closed using SCPInputStream#close
 String getCharset()
          The currently used charset for filename encoding/decoding.
protected  SCPClient.LenNamePair parseCLine(String line)
           
 SCPOutputStream put(String remoteFile, long length, String remoteTargetDirectory, String mode)
          The session for opened for this SCP transfer must be closed using SCPOutputStream#close
protected  void readResponse(InputStream is)
           
protected  String receiveLine(InputStream is)
           
 void setCharset(String charset)
          Set the charset used to convert between Java Unicode Strings and byte encodings used by the server for paths and file names.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SCPClient

public SCPClient(Connection conn)
Method Detail

setCharset

public void setCharset(String charset)
                throws IOException
Set the charset used to convert between Java Unicode Strings and byte encodings used by the server for paths and file names.

Parameters:
charset - the name of the charset to be used or null to use the platform's default encoding.
Throws:
IOException
See Also:
getCharset()

getCharset

public String getCharset()
The currently used charset for filename encoding/decoding.

Returns:
The name of the charset (null if the platform's default charset is being used)
See Also:
setCharset(String)

readResponse

protected void readResponse(InputStream is)
                     throws IOException
Throws:
IOException

receiveLine

protected String receiveLine(InputStream is)
                      throws IOException
Throws:
IOException

parseCLine

protected SCPClient.LenNamePair parseCLine(String line)
                                    throws IOException
Throws:
IOException

put

public SCPOutputStream put(String remoteFile,
                           long length,
                           String remoteTargetDirectory,
                           String mode)
                    throws IOException
The session for opened for this SCP transfer must be closed using SCPOutputStream#close

Parameters:
remoteFile -
length - The size of the file to send
remoteTargetDirectory -
mode -
Returns:
Throws:
IOException

get

public SCPInputStream get(String remoteFile)
                   throws IOException
The session for opened for this SCP transfer must be closed using SCPInputStream#close

Parameters:
remoteFile -
Returns:
Throws:
IOException


Copyright © 2011. All Rights Reserved.