public class SftpFileOutputStream extends OutputStream
// Create an SshClient forcing SSH2 connectivity.
SshConnector con = SshConnector.getInstance();
con.setSupportedVersions(SshConnector.SSH2);
// Connect and authenticate an SshClient
Ssh2Client ssh = (Ssh2Client) con.connect(....);
....
SftpClient sftp=new SftpClient(ssh);
//write file as an input stream
OutputStream out = sftp.getOutputStream("streamTest");
byte[] data="0000000000".getBytes();
for(int i=0;i<10;i++){
out.write(data);
}
out.close();| Constructor and Description |
|---|
SftpFileOutputStream(SftpFile file)
Creates a new SftpFileOutputStream object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the file's handle
|
void |
write(byte[] buffer,
int offset,
int len) |
void |
write(int b) |
flush, writepublic SftpFileOutputStream(SftpFile file) throws SftpStatusException, SshException
file - SftpStatusExceptionSshExceptionpublic void write(byte[] buffer,
int offset,
int len)
throws IOException
write in class OutputStreamIOExceptionpublic void write(int b)
throws IOException
write in class OutputStreamIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOExceptionCopyright © 2025. All rights reserved.