Class BitInputStream


  • public class BitInputStream
    extends java.lang.Object
    This class reads bit by bit data from a back-end stream which is passed in constructor.
    • Constructor Summary

      Constructors 
      Constructor Description
      BitInputStream​(java.io.InputStream stream)
      Constructor for this stream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()
      This method returns approximate number of bits which are available to read.
      void close()
      Releases the resources hold by this instance.
      int read()
      Reads next 1 bit of available data.
      int read​(byte[] b, int bitsPerValue, int length)
      This method breaks the back-end stream into data samples each having "bitsPerValue" number of bits and writes length number of samples to the byte array passed.
      int read​(int nob)
      Reads nob number of bits from available data and returns an integer value.
      int read​(int[] b, int bitsPerValue, int length)
      This method breaks the back-end stream into data samples each having "bitsPerValue" number of bits and writes length number of samples to the byte array passed.
      long skip​(long n)
      This method skips n number of bits from available data.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BitInputStream

        public BitInputStream​(java.io.InputStream stream)
                       throws java.io.IOException
        Constructor for this stream.
        Parameters:
        stream - This stream is used as back-end stream to read bit by bit data.
        Throws:
        java.io.IOException
    • Method Detail

      • read

        public int read​(int nob)
                 throws java.io.IOException
        Reads nob number of bits from available data and returns an integer value. Throws IOException if end of stream has been reached.
        Parameters:
        nob -
        Returns:
        int
        Throws:
        java.io.IOException
      • read

        public int read()
                 throws java.io.IOException
        Reads next 1 bit of available data. Throws IOException if end of stream has been reached.
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Releases the resources hold by this instance.
        Throws:
        java.io.IOException
      • skip

        public long skip​(long n)
                  throws java.io.IOException
        This method skips n number of bits from available data.
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] b,
                        int bitsPerValue,
                        int length)
        This method breaks the back-end stream into data samples each having "bitsPerValue" number of bits and writes length number of samples to the byte array passed. Throws an exception if bitsPerValue is greater than 8 OR byte array passed null OR it's length < "length" Returns the number of values actually written to the byte array.
        Parameters:
        b -
        bitsPerValue -
        Returns:
        int
      • read

        public int read​(int[] b,
                        int bitsPerValue,
                        int length)
        This method breaks the back-end stream into data samples each having "bitsPerValue" number of bits and writes length number of samples to the byte array passed. Throws an exception if byte array passed null OR it's length < "length" Returns the number of values actually written to the byte array.
        Parameters:
        b -
        bitsPerValue -
        Returns:
        int
      • available

        public int available()
                      throws java.io.IOException
        This method returns approximate number of bits which are available to read. Actual number of bits may be more than the count returned by this method but not less than that.
        Returns:
        int
        Throws:
        java.io.IOException