Class BitInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class BitInputStream
    extends java.io.InputStream
    ?r?b?g???????????????[?e?B???e?B?N???X?B
     -- revision history --
     $Log: BitInputStream.java,v $
     Revision 1.5  2002/12/07 00:00:00  dangan
     [maintenance]
         ?\?[?X????
    
     Revision 1.4  2002/11/15 00:00:00  dangan
     [improvement]
         prefetchBits() ??  32bit ???????????????????????????C??
     [change]
         ???\?b?h???????X
         prefetchBit     -> peekBit
         prefetchBoolean -> peekBoolean
         prefetchBits    -> peekBits
    
     Revision 1.3  2002/11/02 00:00:00  dangan
     [bug fix]
         available() availableBits() ??
         ?u???b?N??????????????????????????????l????????????B
    
     Revision 1.2  2002/09/05 00:00:00  dangan
     [change]
         EndOfStream ???B???????? read( new byte[0] ) ?? 
         read( byte[] buf, int off, 0 ) ???????l??
         InputStream ??????? 0 ????????????????
    
     Revision 1.1  2002/09/04 00:00:00  dangan
     [bug fix]
         skip( len ) ?? skipBits( len ) ?? len ?? 0 ?????????
         ??????????????????????????B
    
     Revision 1.0  2002/09/03 00:00:00  dangan
     add to version control
     [bug fix]
         mark() ?? ???}?????? in ???n?? readLimit ???v?Z???????????????A
         ?v???????? readLimit ???B?????O???}?[?N???u???j???????????????????B
         EndOfStream ???B???????? skip() ?N???? skip( 0 ) ?? -1 ????????????B
     [maintenance]
         ?^?u?p?~
         ???C?Z???X????C??
    
    
     
    Version:
    $Revision: 1.5 $
    Author:
    $Author: dangan $
    • Constructor Summary

      Constructors 
      Constructor Description
      BitInputStream​(java.io.InputStream in)
      ?????X?g???[?? in ???????f?[?^???r?b?g?P???? ?????????????????X?g???[?????\?z?????B
      BitInputStream​(java.io.InputStream in, int CacheSize)
      ?????X?g???[?? in ???????f?[?^???r?b?g?P???? ?????????????????X?g???[?????\?z?????B
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()
      ???}???????????X?g???[???????u???b?N??????? ?????????}???????????o?C?g?????????B
      int availableBits()
      ???}???????????X?g???[???????u???b?N??????? ?????????}???????????r?b?g?????????B
      void close()
      ?}???????X?g???[????????A ?g?p??????????\?[?X???J???????B
      void mark​(int readLimit)
      ???}???????????X?g???[???????????u???}?[?N?????????A reset() ???\?b?h???}?[?N???????_?? ???????????u?? ?????????????????B
      boolean markSupported()
      ???}???????????X?g???[???? mark() ?? reset() ?? ?T?|?[?g?????????????B
      int peekBit()
      ???????????u?????????? 1?r?b?g???f?[?^?????????????B
      int peekBits​(int count)
      ???????????u?????????? count ?r?b?g???f?[?^?????????????B
      ?????l?? int?^???????}???????????????????? ?????L???r?b?g???? 32?r?b?g???????B
      EndOfStream ?t??????????A???????o?????}?????????????????? 32?r?b?g???????B(?r?b?g?o?b?t?@?????????? 32?r?b?g??????????)
      ???? 32?r?b?g?????????????@?\???K?{???????????? ?????s?x mark()?AreadBits()?Areset() ???J?????????A ?}???N???X???g?p?????}???????????}???B
      boolean peekBoolean()
      ???????????u?????????? 1?r?b?g???f?[?^?? ?^?U?l?????????????????B
      int read()
      ???}???????X?g???[?????? 8?r?b?g???f?[?^???????????B
      int read​(byte[] buffer)
      ???}???????????X?g???[?????? ?o?C?g?z?? buffer ?? ?????????????f?[?^???????????B
      ?f?[?^???K?????? buffer ????????????????????}?????????B
      int read​(byte[] buffer, int index, int length)
      ???}???????????X?g???[?????? ?o?C?g?z?? buffer ?? index ???w???????????u???? length ?o?C?g???f?[?^?? ?????????B
      ?}?????\?b?h?? length?o?C?g???????????A EndOfStream ?????B?????????u???b?N?????B
      ?f?[?^???K?????? length ?o?C?g???????????????????? ????}?????????B
      int readBit()
      ???}???????????X?g???[?????? 1?r?b?g???f?[?^?? ?????????B
      int readBits​(int count)
      ???}???????????X?g???[?????? count ?r?b?g???f?[?^?? ?????????B ?????l?? int?l???????????????????????? ?????????}?????????? ?????L???r?b?g???? 32?r?b?g?? ???????Acount ??32???????l?????????????`?F?b?N?? ??????????? ???????????l???????????????? ?r?b?g ?f?[?^?????????????????B
      ???????? readBits( 33 ) ???????????? ????1?r?b?g?? ?f?[?^???????????A???????? 32?r?b?g???f?[?^???????B
      ???? count ?? 0?????????????????????????o?????????A ?f?[?^??????????????????????????? ?????l?? ????0?A EndOfStream ???B????????? EOFException ?? ???????_???????????}???B
      boolean readBoolean()
      ???}???????????X?g???[?????? 1?r?b?g???f?[?^?? ?^?U?l???????????????B
      void reset()
      ???}???????????X?g???[???????????????u???????? mark() ???\?b?h???????o???????????????u???????????B
      long skip​(long length)
      ???}???????????X?g???[?????f?[?^?? length ?o?C?g ???????????B
      ?}?????\?b?h?? length?o?C?g?????????????A EndOfStream ?????B?????????u???b?N?????B
      ?f?[?^???K?????? length ?o?C?g?????????????????????? ????}?????????B
      int skipBits​(int count)
      ???}???????X?g???[?????? count ?r?b?g???f?[?^?? ???????????B
      • Methods inherited from class java.io.InputStream

        nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
      • Methods inherited from class java.lang.Object

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

      • BitInputStream

        public BitInputStream​(java.io.InputStream in)
        ?????X?g???[?? in ???????f?[?^???r?b?g?P???? ?????????????????X?g???[?????\?z?????B
        Parameters:
        in - ?????X?g???[??
      • BitInputStream

        public BitInputStream​(java.io.InputStream in,
                              int CacheSize)
        ?????X?g???[?? in ???????f?[?^???r?b?g?P???? ?????????????????X?g???[?????\?z?????B
        Parameters:
        in - ?????X?g???[??
        CacheSize - ?o?b?t?@?T?C?Y
    • Method Detail

      • read

        public int read()
                 throws java.io.IOException
        ???}???????X?g???[?????? 8?r?b?g???f?[?^???????????B
        Specified by:
        read in class java.io.InputStream
        Returns:
        ?????o?????? 8?r?b?g???f?[?^?B
        ???? EndOfStream ???B????????????? -1
        Throws:
        java.io.IOException - ???}???????????X?g???[???? ???o???G???[?????????????
        BitDataBrokenException - EndOfStream???B???????? ?v?????????r?b?g?????f?[?^?? ?????????????s?????????B
      • read

        public int read​(byte[] buffer)
                 throws java.io.IOException
        ???}???????????X?g???[?????? ?o?C?g?z?? buffer ?? ?????????????f?[?^???????????B
        ?f?[?^???K?????? buffer ????????????????????}?????????B
        Overrides:
        read in class java.io.InputStream
        Parameters:
        buffer - ?????????????f?[?^???i?[???????????o?C?g?z??
        Returns:
        buffer ?????????????f?[?^?????o?C?g?????????B
        ???? EndOfStream ???B????????????? -1 ???????B
        Throws:
        java.io.IOException - ???}???????????X?g???[???? ???o???G???[?????????????
        BitDataBrokenException - EndOfStream???B???????? ?v?????????r?b?g?????f?[?^?? ?????????????s?????????B
      • read

        public int read​(byte[] buffer,
                        int index,
                        int length)
                 throws java.io.IOException
        ???}???????????X?g???[?????? ?o?C?g?z?? buffer ?? index ???w???????????u???? length ?o?C?g???f?[?^?? ?????????B
        ?}?????\?b?h?? length?o?C?g???????????A EndOfStream ?????B?????????u???b?N?????B
        ?f?[?^???K?????? length ?o?C?g???????????????????? ????}?????????B
        Overrides:
        read in class java.io.InputStream
        Parameters:
        buffer - ?????????????f?[?^???i?[???????????o?C?g?z??
        index - buffer?????f?[?^?????????J?n???u
        length - buffer???????????f?[?^??
        Returns:
        buffer ?????????????f?[?^?????o?C?g?????????B
        ???? EndOfStream ???B????????????? -1 ???????B
        Throws:
        java.io.IOException - ???}???????????X?g???[???? ???o???G???[?????????????
        BitDataBrokenException - EndOfStream???B???????? ?v?????????r?b?g?????f?[?^?? ?????????????s?????????B
      • skip

        public long skip​(long length)
                  throws java.io.IOException
        ???}???????????X?g???[?????f?[?^?? length ?o?C?g ???????????B
        ?}?????\?b?h?? length?o?C?g?????????????A EndOfStream ?????B?????????u???b?N?????B
        ?f?[?^???K?????? length ?o?C?g?????????????????????? ????}?????????B
        Overrides:
        skip in class java.io.InputStream
        Parameters:
        length - ???????????o?C?g???B
        Returns:
        ?????????????????????o?C?g???B
        Throws:
        java.io.IOException - ???}???????????X?g???[???? ???o???G???[?????????????
      • mark

        public void mark​(int readLimit)
        ???}???????????X?g???[???????????u???}?[?N?????????A reset() ???\?b?h???}?[?N???????_?? ???????????u?? ?????????????????B
        Overrides:
        mark in class java.io.InputStream
        Parameters:
        readLimit - ?}?[?N???u???????????E???o?C?g???B ?}???o?C?g?????L?????f?[?^?????? ?????????? reset()?????????????? ?\?????????B
      • reset

        public void reset()
                   throws java.io.IOException
        ???}???????????X?g???[???????????????u???????? mark() ???\?b?h???????o???????????????u???????????B
        Overrides:
        reset in class java.io.InputStream
        Throws:
        java.io.IOException -
        (1) BitInputStream ?? mark ???????????????????B
        (2) ???}???????????X?g???[???? markSupported()?? false ???????????B
        (3) ???}???????????X?g???[???? ???o???G???[??????????????B
        ?????????B
      • markSupported

        public boolean markSupported()
        ???}???????????X?g???[???? mark() ?? reset() ?? ?T?|?[?g?????????????B
        Overrides:
        markSupported in class java.io.InputStream
        Returns:
        ?X?g???[???? mark() ?? reset() ?? ?T?|?[?g?????????? true?B
        ?T?|?[?g??????????? false?B
      • available

        public int available()
                      throws java.io.IOException
        ???}???????????X?g???[???????u???b?N??????? ?????????}???????????o?C?g?????????B
        Overrides:
        available in class java.io.InputStream
        Returns:
        ?u???b?N????????????o?????o?C?g???B
        Throws:
        java.io.IOException - ???}???????????X?g???[???? ???o???G???[?????????????
      • close

        public void close()
                   throws java.io.IOException
        ?}???????X?g???[????????A ?g?p??????????\?[?X???J???????B
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.InputStream
        Throws:
        java.io.IOException - ???}???????????X?g???[???? ???o???G???[?????????????
      • readBit

        public int readBit()
                    throws java.io.IOException
        ???}???????????X?g???[?????? 1?r?b?g???f?[?^?? ?????????B
        Returns:
        ????????????1?r?b?g???f?[?^?B
        ????EndOfStream???B????????????? -1?B
        Throws:
        java.io.IOException - ???}???????????X?g???[???? ???o???G???[?????????????
      • readBoolean

        public boolean readBoolean()
                            throws java.io.IOException
        ???}???????????X?g???[?????? 1?r?b?g???f?[?^?? ?^?U?l???????????????B
        Returns:
        ????????????1?r?b?g???f?[?^?? 1???????? true?A0???????? false ???????B
        Throws:
        java.io.EOFException - ????EndOfStream???B???????????
        java.io.IOException - ???}???????????X?g???[???? ???o???G???[?????????????
      • readBits

        public int readBits​(int count)
                     throws java.io.IOException
        ???}???????????X?g???[?????? count ?r?b?g???f?[?^?? ?????????B ?????l?? int?l???????????????????????? ?????????}?????????? ?????L???r?b?g???? 32?r?b?g?? ???????Acount ??32???????l?????????????`?F?b?N?? ??????????? ???????????l???????????????? ?r?b?g ?f?[?^?????????????????B
        ???????? readBits( 33 ) ???????????? ????1?r?b?g?? ?f?[?^???????????A???????? 32?r?b?g???f?[?^???????B
        ???? count ?? 0?????????????????????????o?????????A ?f?[?^??????????????????????????? ?????l?? ????0?A EndOfStream ???B????????? EOFException ?? ???????_???????????}???B
        Parameters:
        count - ?????????f?[?^???r?b?g??
        Returns:
        ?????????????r?b?g?f?[?^?B
        Throws:
        java.io.IOException - ???}???????????X?g???[???? ???o???G???[?????????????
        java.io.EOFException - ????EndOfStream???B???????????
        BitDataBrokenException - ?????????r???? EndOfStream???B???????? ?v?????????r?b?g?????f?[?^?????????? ?????s?????????B
      • skipBits

        public int skipBits​(int count)
                     throws java.io.IOException
        ???}???????X?g???[?????? count ?r?b?g???f?[?^?? ???????????B
        Parameters:
        count - ??????????????????r?b?g??
        Returns:
        ???????????????????r?b?g??
        Throws:
        java.io.IOException - ???}???????????X?g???[???? ???o???G???[?????????????
      • peekBit

        public int peekBit()
                    throws java.io.IOException
        ???????????u?????????? 1?r?b?g???f?[?^?????????????B
        Returns:
        ????????????1?r?b?g???f?[?^?B
        ????EndOfStream???B????????????? -1?B
        Throws:
        java.io.IOException - ???}???????????X?g???[???? ???o???G???[?????????????
      • peekBoolean

        public boolean peekBoolean()
                            throws java.io.IOException
        ???????????u?????????? 1?r?b?g???f?[?^?? ?^?U?l?????????????????B
        Returns:
        ????????????1?r?b?g???f?[?^?? 1???????? true?A0???????? false ???????B
        Throws:
        java.io.EOFException - ????EndOfStream???B???????????
        java.io.IOException - ???}???????????X?g???[???? ???o???G???[?????????????
      • peekBits

        public int peekBits​(int count)
                     throws java.io.IOException
        ???????????u?????????? count ?r?b?g???f?[?^?????????????B
        ?????l?? int?^???????}???????????????????? ?????L???r?b?g???? 32?r?b?g???????B
        EndOfStream ?t??????????A???????o?????}?????????????????? 32?r?b?g???????B(?r?b?g?o?b?t?@?????????? 32?r?b?g??????????)
        ???? 32?r?b?g?????????????@?\???K?{???????????? ?????s?x mark()?AreadBits()?Areset() ???J?????????A ?}???N???X???g?p?????}???????????}???B
        Parameters:
        count - ?????????r?b?g??
        Returns:
        ?????????? count ?r?b?g???r?b?g?f?[?^
        Throws:
        java.io.EOFException - ????EndOfStream???B???????????
        java.io.IOException - ???}???????????X?g???[???? ???o???G???[?????????????
        NotEnoughBitsException - count ???????????\???????O??????
      • availableBits

        public int availableBits()
                          throws java.io.IOException
        ???}???????????X?g???[???????u???b?N??????? ?????????}???????????r?b?g?????????B
        Returns:
        ?u???b?N????????????o?????r?b?g???B
        Throws:
        java.io.IOException - ???}???????????X?g???[???? ???o???G???[?????????????