// 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();
- Author:
- Lee David Painter
|
Method Summary |
void |
close()
Closes the file's handle |
protected void |
finalize()
This method will only be available in J2SE builds |
void |
write(byte[] buffer,
int offset,
int len)
|
void |
write(int b)
|
| Methods inherited from class java.io.OutputStream |
flush, write |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SftpFileOutputStream
public SftpFileOutputStream(SftpFile file)
throws SftpStatusException,
SshException
- Creates a new SftpFileOutputStream object.
- Parameters:
file -
- Throws:
SftpStatusException
SshException
write
public void write(byte[] buffer,
int offset,
int len)
throws java.io.IOException
- Overrides:
write in class java.io.OutputStream
- Throws:
java.io.IOException
write
public void write(int b)
throws java.io.IOException
- Specified by:
write in class java.io.OutputStream
- Throws:
java.io.IOException
close
public void close()
throws java.io.IOException
- Closes the file's handle
- Specified by:
close in interface java.io.Closeable- Overrides:
close in class java.io.OutputStream
- Throws:
java.io.IOException
finalize
protected void finalize()
throws java.io.IOException
- This method will only be available in J2SE builds
- Overrides:
finalize in class java.lang.Object
- Throws:
java.io.IOException
Copyright © 2003-2008 SSHTools LTD. All Rights Reserved.