Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
    
  
  
  
  
    
  
  
    
    
  
  
  public
  
  
  
  class
  CheckedInputStream
  
  
  
  
  
  
  
    extends FilterInputStream
  
  
  
  
  
  
  
    
  An input stream that also maintains a checksum of the data being read.
 The checksum can then be used to verify the integrity of the input data.
  
Summary
Public methods | 
  
  
  
    
        
        
        
        
        
        Checksum
     | 
  
    
      
      getChecksum()
      
      
        Returns the Checksum for this input stream.
        
    
 
      
     | 
  
  
  
  
  
    
        
        
        
        
        
        int
     | 
  
    
      
      read()
      
      
        Reads a byte.
        
    
 
      
     | 
  
  
  
  
  
    
        
        
        
        
        
        int
     | 
  
    
      
      read(byte[] buf, int off, int len)
      
      
        Reads into an array of bytes.
        
    
 
      
     | 
  
  
  
  
  
    
        
        
        
        
        
        long
     | 
  
    
      
      skip(long n)
      
      
        Skips specified number of bytes of input.
        
    
 
      
     | 
  
  
Inherited methods | 
  
    From class
      
        
          java.io.FilterInputStream
        
      
    
    
      
  
  
  
    
        
        
        
        
        
        int
     | 
  
    
      
      available()
      
      
        Returns an estimate of the number of bytes that can be read (or
 skipped over) from this input stream without blocking by the next
 caller of a method for this input stream.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        void
     | 
  
    
      
      close()
      
      
        Closes this input stream and releases any system resources
 associated with the stream.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        void
     | 
  
    
      
      mark(int readlimit)
      
      
        Marks the current position in this input stream.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        boolean
     | 
  
    
      
      markSupported()
      
      
        Tests if this input stream supports the mark
 and reset methods.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        int
     | 
  
    
      
      read()
      
      
        Reads the next byte of data from this input stream.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        int
     | 
  
    
      
      read(byte[] b, int off, int len)
      
      
        Reads up to len bytes of data from this input stream
 into an array of bytes.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        int
     | 
  
    
      
      read(byte[] b)
      
      
        Reads up to b.length bytes of data from this
 input stream into an array of bytes.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        void
     | 
  
    
      
      reset()
      
      
        Repositions this stream to the position at the time the
 mark method was last called on this input stream.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        long
     | 
  
    
      
      skip(long n)
      
      
        Skips over and discards n bytes of data from the
 input stream.
        
    
 
      
     | 
   
  
     
   
 | 
  
    From class
      
        
          java.io.InputStream
        
      
    
    
      
  
  
  
    
        
        
        
        
        
        int
     | 
  
    
      
      available()
      
      
        Returns an estimate of the number of bytes that can be read (or skipped
 over) from this input stream without blocking, which may be 0, or 0 when
 end of stream is detected.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        void
     | 
  
    
      
      close()
      
      
        Closes this input stream and releases any system resources associated
 with the stream.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        void
     | 
  
    
      
      mark(int readlimit)
      
      
        Marks the current position in this input stream.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        boolean
     | 
  
    
      
      markSupported()
      
      
        Tests if this input stream supports the mark and
 reset methods.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        static
        
        
        InputStream
     | 
  
    
      
      nullInputStream()
      
      
        Returns a new InputStream that reads no bytes.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        int
     | 
  
    
      
      read(byte[] b)
      
      
        Reads some number of bytes from the input stream and stores them into
 the buffer array b.
        
    
 
      
     | 
   
  
  
  
  
    
        abstract
        
        
        
        
        int
     | 
  
    
      
      read()
      
      
        Reads the next byte of data from the input stream.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        int
     | 
  
    
      
      read(byte[] b, int off, int len)
      
      
        Reads up to len bytes of data from the input stream into
 an array of bytes.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        byte[]
     | 
  
    
      
      readAllBytes()
      
      
        Reads all remaining bytes from the input stream.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        int
     | 
  
    
      
      readNBytes(byte[] b, int off, int len)
      
      
        Reads the requested number of bytes from the input stream into the given
 byte array.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        byte[]
     | 
  
    
      
      readNBytes(int len)
      
      
        Reads up to a specified number of bytes from the input stream.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        void
     | 
  
    
      
      reset()
      
      
        Repositions this stream to the position at the time the
 mark method was last called on this input stream.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        long
     | 
  
    
      
      skip(long n)
      
      
        Skips over and discards n bytes of data from this input
 stream.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        void
     | 
  
    
      
      skipNBytes(long n)
      
      
        Skips over and discards exactly n bytes of data from this input
 stream.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        long
     | 
  
    
      
      transferTo(OutputStream out)
      
      
        Reads all bytes from this input stream and writes the bytes to the
 given output stream in the order that they are read.
        
    
 
      
     | 
   
  
     
   
 | 
  
    From class
      
        
          java.lang.Object
        
      
    
    
      
  
  
  
    
        
        
        
        
        
        Object
     | 
  
    
      
      clone()
      
      
        Creates and returns a copy of this object.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        boolean
     | 
  
    
      
      equals(Object obj)
      
      
        Indicates whether some other object is "equal to" this one.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        void
     | 
  
    
      
      finalize()
      
      
        Called by the garbage collector on an object when garbage collection
 determines that there are no more references to the object.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        final
        
        Class<?>
     | 
  
    
      
      getClass()
      
      
        Returns the runtime class of this Object.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        int
     | 
  
    
      
      hashCode()
      
      
        Returns a hash code value for the object.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        final
        
        void
     | 
  
    
      
      notify()
      
      
        Wakes up a single thread that is waiting on this object's
 monitor.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        final
        
        void
     | 
  
    
      
      notifyAll()
      
      
        Wakes up all threads that are waiting on this object's monitor.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        
        
        String
     | 
  
    
      
      toString()
      
      
        Returns a string representation of the object.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        final
        
        void
     | 
  
    
      
      wait(long timeoutMillis, int nanos)
      
      
        Causes the current thread to wait until it is awakened, typically
 by being notified or interrupted, or until a
 certain amount of real time has elapsed.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        final
        
        void
     | 
  
    
      
      wait(long timeoutMillis)
      
      
        Causes the current thread to wait until it is awakened, typically
 by being notified or interrupted, or until a
 certain amount of real time has elapsed.
        
    
 
      
     | 
   
  
  
  
  
    
        
        
        
        final
        
        void
     | 
  
    
      
      wait()
      
      
        Causes the current thread to wait until it is awakened, typically
 by being notified or interrupted.
        
    
 
      
     | 
   
  
     
   
 | 
  
    From interface
      
        
          java.io.Closeable
        
      
    
    
      
  
  
  
    
        abstract
        
        
        
        
        void
     | 
  
    
      
      close()
      
      
        Closes this stream and releases any system resources associated
 with it.
        
    
 
      
     | 
   
  
     
   
 | 
| 
  
 | 
Public constructors
    
    
public CheckedInputStream (InputStream in, 
                Checksum cksum)
    
    
    
  Creates an input stream using the specified Checksum.
    
    | Parameters | 
      
        in | 
        
          InputStream: the input stream | 
      
      
        cksum | 
        
          Checksum: the Checksum | 
      
    
 
Public methods
    getChecksum
    
public Checksum getChecksum ()
    
    
    
  Returns the Checksum for this input stream.
    
 
    read
    
public int read ()
    
    
    
  Reads a byte. Will block if no input is available.
    
      | Returns | 
      
        int | 
        the byte read, or -1 if the end of the stream is reached. | 
      
    
      
  
 
    read
    
public int read (byte[] buf, 
                int off, 
                int len)
    
    
    
  Reads into an array of bytes. If len is not zero, the method
 blocks until some input is available; otherwise, no
 bytes are read and 0 is returned.
    
    | Parameters | 
      
        buf | 
        
          byte: the buffer into which the data is read | 
      
      
        off | 
        
          int: the start offset in the destination array b | 
      
      
        len | 
        
          int: the maximum number of bytes read | 
      
    
    
      | Returns | 
      
        int | 
        the actual number of bytes read, or -1 if the end
            of the stream is reached. | 
      
    
      
  
 
    skip
    
public long skip (long n)
    
    
    
  Skips specified number of bytes of input.
    
    | Parameters | 
      
        n | 
        
          long: the number of bytes to skip | 
      
    
    
      | Returns | 
      
        long | 
        the actual number of bytes skipped | 
      
    
      
  
 
 
 
  
  
    
  
 
  
    
    
      
       
    
    
  
  
  Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
  Last updated 2025-02-10 UTC.
  
  
  
    
      [null,null,["Last updated 2025-02-10 UTC."],[],[]]