com.enterprisedt.net.ftp.ssh
Class SSHFTPOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by com.enterprisedt.net.ftp.FileTransferOutputStream
          extended by com.enterprisedt.net.ftp.ssh.SSHFTPOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class SSHFTPOutputStream
extends FileTransferOutputStream

An output stream that writes to an SFTP server, permitting the user to upload a file by writing to the stream. It can only be used for one upload, i.e. after the stream is closed it cannot be reopened.

Version:
$Revision: 1.3 $
Author:
Bruce Blackshaw

Field Summary
 
Fields inherited from class com.enterprisedt.net.ftp.FileTransferOutputStream
closed, remoteFile
 
Constructor Summary
SSHFTPOutputStream(SSHFTPClient client, java.lang.String remoteFile)
          Constructor.
SSHFTPOutputStream(SSHFTPClient client, java.lang.String remoteFile, boolean append)
          Constructor.
 
Method Summary
 void close()
          Closes this output stream and releases any system resources associated with the stream.
 java.lang.String getRemoteFile()
          Get the name of the remote file
 void setMonitor(FTPProgressMonitorEx monitor, long monitorInterval)
          The output stream uses the progress monitor currently owned by the SSHFTPClient.
 void write(byte[] b, int off, int len)
          Writes len bytes from the specified byte array starting at offset off to this output stream.
 void write(int b)
          Writes b.length bytes from the specified byte array to this output stream.
 
Methods inherited from class java.io.OutputStream
flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SSHFTPOutputStream

public SSHFTPOutputStream(SSHFTPClient client,
                          java.lang.String remoteFile)
                   throws java.io.IOException,
                          FTPException
Constructor. A connected SSHFTPClient instance must be supplied.

Parameters:
client - connected SSHFTPClient instance
remoteFile - name of remote file
Throws:
java.io.IOException
FTPException

SSHFTPOutputStream

public SSHFTPOutputStream(SSHFTPClient client,
                          java.lang.String remoteFile,
                          boolean append)
                   throws java.io.IOException,
                          FTPException
Constructor. A connected SSHFTPClient instance must be supplied. This sets up the download.

Parameters:
client - connected SSHFTPClient instance
remoteFile - name of remote file
append - true if appending on the server
Throws:
java.io.IOException
FTPException
Method Detail

getRemoteFile

public java.lang.String getRemoteFile()
Get the name of the remote file

Overrides:
getRemoteFile in class FileTransferOutputStream
Returns:
remote filename

setMonitor

public void setMonitor(FTPProgressMonitorEx monitor,
                       long monitorInterval)
The output stream uses the progress monitor currently owned by the SSHFTPClient. This method allows a different progress monitor to be passed in, or for the monitor interval to be altered.

Parameters:
monitor - progress monitor reference
monitorInterval -

write

public void write(int b)
           throws java.io.IOException
Writes b.length bytes from the specified byte array to this output stream.

Specified by:
write in class java.io.OutputStream
Parameters:
b - the data.
Throws:
java.io.IOException - if an I/O error occurs.

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Writes len bytes from the specified byte array starting at offset off to this output stream.

Overrides:
write in class java.io.OutputStream
Parameters:
b - the data.
off - the start offset in the data.
len - the number of bytes to write.
Throws:
java.io.IOException - if an I/O error occurs.

close

public void close()
           throws java.io.IOException
Closes this output stream and releases any system resources associated with the stream. This must be called before any other operations are initiated on the FTPClient.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException - if an I/O error occurs.


Copyright © 2001-2006 Enterprise Distributed Technologies Ltd. All Rights Reserved.