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, write
public SftpFileOutputStream(SftpFile file) throws SftpStatusException, SshException
file
- SftpStatusException
SshException
public void write(byte[] buffer, int offset, int len) throws IOException
write
in class OutputStream
IOException
public void write(int b) throws IOException
write
in class OutputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
Copyright © 2024. All rights reserved.