com.sshtools.scp
Class ScpClientIO.ScpEngineIO

java.lang.Object
  extended by com.sshtools.scp.ScpClientIO.ScpEngineIO
Direct Known Subclasses:
ScpClient.ScpEngine
Enclosing class:
ScpClientIO

public class ScpClientIO.ScpEngineIO
extends Object

Implements an SCP engine.


Field Summary
protected  byte[] buffer
           
protected  String cmd
           
protected  InputStream in
           
protected  OutputStream out
           
protected  SshSession session
           
 
Constructor Summary
protected ScpClientIO.ScpEngineIO(String cmd, SshSession session)
           Contruct the channel with the specified scp command.
 
Method Summary
 void close()
          Close the SCP engine and underlying session.
protected  void parseCommand(String cmd, String[] cmdParts)
          Parse an SCP command
protected  void readCompleteFile(OutputStream out, long size, FileTransferProgress progress)
           
protected  InputStream readStreamFromRemote(String remoteFile, FileTransferProgress progress)
          Open an InputStream.
protected  String readString()
          read the inputstream until come to an end of line character '\n', and return the bytes read as a string
 void waitForResponse()
           
protected  void writeCompleteFile(InputStream in, long size, FileTransferProgress progress)
           
protected  void writeError(String reason)
           
protected  void writeOk()
           
protected  void writeStreamToRemote(InputStream in, long length, String baseName, FileTransferProgress progress)
           Write a stream as a file to the remote server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buffer

protected byte[] buffer

cmd

protected String cmd

session

protected SshSession session

out

protected OutputStream out

in

protected InputStream in
Constructor Detail

ScpClientIO.ScpEngineIO

protected ScpClientIO.ScpEngineIO(String cmd,
                                  SshSession session)
                           throws SshException

Contruct the channel with the specified scp command.

Parameters:
cmd - the scp command
session - the session to scp over
Throws:
SshException
Method Detail

close

public void close()
           throws SshException
Close the SCP engine and underlying session.

Throws:
SshException

writeStreamToRemote

protected void writeStreamToRemote(InputStream in,
                                   long length,
                                   String baseName,
                                   FileTransferProgress progress)
                            throws IOException

Write a stream as a file to the remote server. You must supply the correct number of bytes that will be written.

Parameters:
in - stream
length - number of bytes to write
baseName - base file name
Throws:
IOException - if an IO error occurs

readStreamFromRemote

protected InputStream readStreamFromRemote(String remoteFile,
                                           FileTransferProgress progress)
                                    throws IOException
Open an InputStream.

Parameters:
remoteFile -
progress -
Returns:
ScpInputStream
Throws:
IOException

parseCommand

protected void parseCommand(String cmd,
                            String[] cmdParts)
                     throws IOException
Parse an SCP command

Parameters:
cmd -
cmdParts -
Throws:
IOException

readString

protected String readString()
                     throws IOException
read the inputstream until come to an end of line character '\n', and return the bytes read as a string

Returns:
String
Throws:
IOException

waitForResponse

public void waitForResponse()
                     throws IOException
Throws:
IOException

writeOk

protected void writeOk()
                throws IOException
Throws:
IOException

writeError

protected void writeError(String reason)
                   throws IOException
Throws:
IOException

writeCompleteFile

protected void writeCompleteFile(InputStream in,
                                 long size,
                                 FileTransferProgress progress)
                          throws IOException
Throws:
IOException

readCompleteFile

protected void readCompleteFile(OutputStream out,
                                long size,
                                FileTransferProgress progress)
                         throws IOException
Throws:
IOException


Copyright © 2012. All Rights Reserved.