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.
|
protected void |
finalize()
This method will only be available in J2SE builds
|
int |
read() |
int |
read(byte[] buffer,
int offset,
int len) |
void |
setMaximumAsyncRequests(int maximumAsyncRequests) |
mark, markSupported, read, reset, skip
public SftpFileInputStream(SftpFile file) throws SftpStatusException, SshException
file
- SftpStatusException
SshException
public SftpFileInputStream(SftpFile file, long position) throws SftpStatusException, SshException
file
- position
- at which to start readingSftpStatusException
SshException
public void setMaximumAsyncRequests(int maximumAsyncRequests)
public int read(byte[] buffer, int offset, int len) throws IOException
read
in class InputStream
IOException
public int available()
available
in class InputStream
public int read() throws IOException
read
in class InputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
protected void finalize() throws IOException
finalize
in class Object
IOException
Copyright © 2024. All rights reserved.