Package com.enterprisedt.net.ftp.ssh
Class SSHFTPOutputStream
java.lang.Object
java.io.OutputStream
com.enterprisedt.net.ftp.FileTransferOutputStream
com.enterprisedt.net.ftp.ssh.SSHFTPOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
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
-
Field Summary
Fields inherited from class com.enterprisedt.net.ftp.FileTransferOutputStream
closed, remoteFile, size -
Constructor Summary
ConstructorsConstructorDescriptionSSHFTPOutputStream(SSHFTPClient client, String remoteFile) Constructor.SSHFTPOutputStream(SSHFTPClient client, String remoteFile, boolean append) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this output stream and releases any system resources associated with the stream.Get the name of the remote filevoidsetMonitor(FTPProgressMonitorEx monitor, long monitorInterval) The output stream uses the progress monitor currently owned by the SSHFTPClient.voidwrite(byte[] b, int off, int len) Writeslenbytes from the specified byte array starting at offsetoffto this output stream.voidwrite(int b) Writesb.lengthbytes from the specified byte array to this output stream.Methods inherited from class com.enterprisedt.net.ftp.FileTransferOutputStream
getBytesTransferredMethods inherited from class java.io.OutputStream
flush, nullOutputStream, write
-
Constructor Details
-
SSHFTPOutputStream
Constructor. A connected SSHFTPClient instance must be supplied.- Parameters:
client- connected SSHFTPClient instanceremoteFile- name of remote file- Throws:
IOExceptionFTPException
-
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 instanceremoteFile- name of remote fileappend- true if appending on the server- Throws:
IOExceptionFTPException
-
-
Method Details
-
getRemoteFile
Get the name of the remote file- Overrides:
getRemoteFilein classFileTransferOutputStream- Returns:
- remote filename
-
setMonitor
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 referencemonitorInterval-
-
write
Writesb.lengthbytes from the specified byte array to this output stream.- Specified by:
writein classOutputStream- Parameters:
b- the data.- Throws:
IOException- if an I/O error occurs.
-
write
Writeslenbytes from the specified byte array starting at offsetoffto this output stream.- Overrides:
writein classOutputStream- 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
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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException- if an I/O error occurs.
-