public class SftpFileInputStream extends InputStream
An InputStream to read the contents of a remote file.
// 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);
//read file as input stream
InputStream in = sftp.getInputStream("streamTest");
// Read the data
int read;
while((read = in.read()) > -1){
//do something with data
}
// Close the file and the stream
in.close();| Constructor and Description |
|---|
SftpFileInputStream(SftpFile file) |
SftpFileInputStream(SftpFile file,
long position)
Creates a new SftpFileInputStream object.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
close()
Closes the SFTP file handle.
|
int |
read() |
int |
read(byte[] buffer,
int offset,
int len) |
mark, markSupported, read, reset, skippublic SftpFileInputStream(SftpFile file) throws SftpStatusException, SshException
file - SftpStatusExceptionSshExceptionpublic SftpFileInputStream(SftpFile file, long position) throws SftpStatusException, SshException
file - position - at which to start readingSftpStatusExceptionSshExceptionpublic int read(byte[] buffer,
int offset,
int len)
throws IOException
read in class InputStreamIOExceptionpublic int available()
available in class InputStreampublic int read()
throws IOException
read in class InputStreamIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOExceptionCopyright © 2014. All rights reserved.