Class SSHFTPOutputStream

All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

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$
Author:
Bruce Blackshaw
  • Constructor Details

    • SSHFTPOutputStream

      public SSHFTPOutputStream(SSHFTPClient client, String remoteFile) throws IOException, FTPException
      Constructor. A connected SSHFTPClient instance must be supplied.
      Parameters:
      client - connected SSHFTPClient instance
      remoteFile - name of remote file
      Throws:
      IOException
      FTPException
    • SSHFTPOutputStream

      public SSHFTPOutputStream(SSHFTPClient client, String remoteFile, boolean append) throws 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:
      IOException
      FTPException
  • Method Details

    • getRemoteFile

      public 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 IOException
      Writes b.length bytes from the specified byte array to this output stream.
      Specified by:
      write in class OutputStream
      Parameters:
      b - the data.
      Throws:
      IOException - if an I/O error occurs.
    • write

      public void write(byte[] b, int off, int len) throws IOException
      Writes len bytes from the specified byte array starting at offset off to this output stream.
      Overrides:
      write in class OutputStream
      Parameters:
      b - the data.
      off - the start offset in the data.
      len - the number of bytes to write.
      Throws:
      IOException - if an I/O error occurs.
    • close

      public void close() throws 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 AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OutputStream
      Throws:
      IOException - if an I/O error occurs.