Module jcifs

Class SmbFileInputStream

java.lang.Object
java.io.InputStream
org.codelibs.jcifs.smb.impl.SmbFileInputStream
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
SmbPipeInputStream

public class SmbFileInputStream extends InputStream
This InputStream can read bytes from a file on an SMB file server. Offsets are 64 bits.
  • Constructor Details

    • SmbFileInputStream

      public SmbFileInputStream(String url, CIFSContext tc) throws SmbException, MalformedURLException
      Creates an input stream for reading from the specified SMB URL
      Parameters:
      url - the SMB URL to read from
      tc - context to use
      Throws:
      SmbException - if an SMB error occurs
      MalformedURLException - if the URL is malformed
    • SmbFileInputStream

      public SmbFileInputStream(SmbFile file) throws SmbException
      Creates an InputStream for reading bytes from a file on an SMB server represented by the SmbFile parameter. See SmbFile for a detailed description and examples of the smb URL syntax.
      Parameters:
      file - An SmbFile specifying the file to read from
      Throws:
      SmbException - if an SMB error occurs
  • Method Details

    • open

      public void open() throws CIFSException
      Ensures that the file descriptor is openend
      Throws:
      CIFSException - if an error occurs while opening the file
    • seToIoe

      protected static IOException seToIoe(SmbException se)
      Converts an SmbException to an IOException
      Parameters:
      se - the SmbException to convert
      Returns:
      an IOException wrapping the SmbException
    • close

      public void close() throws IOException
      Closes this input stream and releases any system resources associated with the stream.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream
      Throws:
      IOException - if a network error occurs
    • read

      public int read() throws IOException
      Reads a byte of data from this input stream.
      Specified by:
      read in class InputStream
      Throws:
      IOException - if a network error occurs
    • read

      public int read(byte[] b) throws IOException
      Reads up to b.length bytes of data from this input stream into an array of bytes.
      Overrides:
      read in class InputStream
      Throws:
      IOException - if a network error occurs
    • read

      public int read(byte[] b, int off, int len) throws IOException
      Reads up to len bytes of data from this input stream into an array of bytes.
      Overrides:
      read in class InputStream
      Throws:
      IOException - if a network error occurs
    • readDirect

      public int readDirect(byte[] b, int off, int len) throws IOException
      Reads up to len bytes of data from this input stream into an array of bytes.
      Parameters:
      b - the buffer to read into
      off - the offset in the buffer to start writing
      len - the maximum number of bytes to read
      Returns:
      number of bytes read
      Throws:
      IOException - if a network error occurs
    • available

      public int available() throws IOException
      This stream class is unbuffered. Therefore this method will always return 0 for streams connected to regular files. However, a stream created from a Named Pipe this method will query the server using a "peek named pipe" operation and return the number of available bytes on the server.
      Overrides:
      available in class InputStream
      Throws:
      IOException
    • skip

      public long skip(long n) throws IOException
      Skip n bytes of data on this stream. This operation will not result in any IO with the server. Unlink InputStream value less than the one provided will not be returned if it exceeds the end of the file (if this is a problem let us know).
      Overrides:
      skip in class InputStream
      Throws:
      IOException