Package com.sshtools.client.scp
Class ScpClientIO.ScpEngineIO
java.lang.Object
com.sshtools.client.scp.ScpClientIO.ScpEngineIO
- Direct Known Subclasses:
ScpClient.ScpEngine
- Enclosing class:
- ScpClientIO
Implements an SCP engine.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]
protected String
protected InputStream
protected OutputStream
protected com.sshtools.common.ssh.SessionChannel
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ScpEngineIO
(String cmd, SessionChannelNG session) Contruct the channel with the specified scp command. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the SCP engine and underlying session.protected void
parseCommand
(String cmd, String[] cmdParts) Parse an SCP commandprotected void
readCompleteFile
(OutputStream out, long size, FileTransferProgress progress) protected InputStream
readStreamFromRemote
(String remoteFile, FileTransferProgress progress) Open an InputStream.protected String
read the inputstream until come to an end of line character '\n', and return the bytes read as a stringvoid
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 localName, FileTransferProgress progress) Write a stream as a file to the remote server.
-
Field Details
-
buffer
protected byte[] buffer -
cmd
-
session
protected com.sshtools.common.ssh.SessionChannel session -
out
-
in
-
-
Constructor Details
-
ScpEngineIO
protected ScpEngineIO(String cmd, SessionChannelNG session) throws com.sshtools.common.ssh.SshException Contruct the channel with the specified scp command.
- Parameters:
cmd
- the scp commandsession
- the session to scp over- Throws:
com.sshtools.common.ssh.SshException
-
-
Method Details
-
close
public void close() throws com.sshtools.common.ssh.SshExceptionClose the SCP engine and underlying session.- Throws:
com.sshtools.common.ssh.SshException
-
writeStreamToRemote
protected void writeStreamToRemote(InputStream in, long length, String localName, 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
- streamlength
- number of bytes to writelocalName
- local 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
Parse an SCP command- Parameters:
cmd
-cmdParts
-- Throws:
IOException
-
readString
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
- Throws:
IOException
-
writeOk
- Throws:
IOException
-
writeError
- 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
-