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 | 
| protected boolean | isEOFMessage(int status) | 
| int | read() | 
| int | read(byte[] buffer,
    int offset,
    int len) | 
| void | setMaximumAsyncRequests(int maximumAsyncRequests) | 
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 void setMaximumAsyncRequests(int maximumAsyncRequests)
public int read(byte[] buffer,
                int offset,
                int len)
         throws IOException
read in class InputStreamIOExceptionprotected boolean isEOFMessage(int status)
public 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 InputStreamIOExceptionprotected void finalize()
                 throws IOException
finalize in class ObjectIOExceptionCopyright © 2025. All rights reserved.