Class CachedInputStream

java.lang.Object
java.io.InputStream
jp.gr.java_conf.dangan.io.CachedInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class CachedInputStream extends InputStream
?L???b?V?????g?p????????????????????????X?g???[???B
BufferedInputStream ???? read?n???\?b?h?? synchronized ???????????????A?????????????????X??????Amark/reset ?? ?L???b?V?????????????????u?????????s?????????????T?|?[?g???????A ?????????????}???????????X?g???[???????\???????A??????????????B
 -- revision history --
 $Log: CachedInputStream.java,v $
 Revision 1.3  2002/12/05 00:00:00  dangan
 [maintenance]
     ?\?[?X????

 Revision 1.2  2002/11/02 00:00:00  dangan
 [bug fix]
     available() ???u???b?N??????????????????????????????l????????????B

 Revision 1.1  2002/09/05 00:00:00  dangan
 [change]
     EndOfStream ???B???????? read( new byte[0] ) ?? 
     read( byte[] buf, int off, 0 ) ???????l??
     InputStream ??????? 0 ?????????????????B

 Revision 1.0  2002/09/05 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
     read( buf, off, len ) ???? System.arraycopy ???????o???? 
     dst ?? src ???t??????????B
 [change]
     EndOfStream ???B???????? read( new byte[0] ) ??
     read( buf, off?C0 )  ?? -1 ?????????????C???B
 [maintenance]
     ?^?u?p?~
     ???C?Z???X????C??

 
Version:
$Revision: 1.3 $
Author:
$Author: dangan $
  • Constructor Summary

    Constructors
    Constructor
    Description
    ?f?t?H???g???T?C?Y???L???b?V???????? CachedInputStream???\?z?????B
    CachedInputStream(InputStream in, int cacheSize)
    ?w?????????T?C?Y???L???b?V???????? CachedInputStream???\?z?????B
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    ???}???????????X?g???[???????u???b?N??????? ?????????}???????????o?C?g?????????B
    void
    ?}???????X?g???[????????A?g?p??????? ?S???????\?[?X???J???????B
    void
    mark(int readLimit)
    ???}???????????X?g???[???????????u???}?[?N?????????A reset() ???\?b?h???}?[?N???????_?? ???????????u?? ?????????????????B
    boolean
    ???}???????????X?g???[???? mark() ?? reset() ?? ?T?|?[?g?????????????B
    int
    ???}???????X?g???[?????? 1?o?C?g???f?[?^?? 0?`255 ???}?b?v?????????????B
    int
    read(byte[] buffer)
    ???}???????X?g???[?????? buffer?????????????? ?f?[?^???????????B
    ?}?????\?b?h?? buffer ?????????????f?[?^?????????????A EndOfStream?????B?????????u???b?N?????B
    int
    read(byte[] buffer, int index, int length)
    ???}???????X?g???[?????? buffer ?? index ???w???????? ???u?? length ?o?C?g?f?[?^???????????B
    ?}?????\?b?h?? length ?o?C?g???????????A EndOfStream?????B?????????u???b?N?????B
    void
    ???}???????????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???????????? EndOfStream ?????B?????????u???b?N?????B

    Methods inherited from class java.lang.Object

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

    • CachedInputStream

      public CachedInputStream(InputStream in)
      ?f?t?H???g???T?C?Y???L???b?V???????? CachedInputStream???\?z?????B
      Parameters:
      in - ?L???b?V?????K?v???????X?g???[??
      Throws:
      IllegalArgumentException - in ?? null ??????????
    • CachedInputStream

      public CachedInputStream(InputStream in, int cacheSize)
      ?w?????????T?C?Y???L???b?V???????? CachedInputStream???\?z?????B
      Parameters:
      in - ?L???b?V?????K?v???????X?g???[??
      cacheSize - ?L???b?V?????T?C?Y
      Throws:
      IllegalArgumentException - cacheSize ?? 0?????????????A in ?? null ??????????
  • Method Details

    • read

      public int read() throws IOException
      ???}???????X?g???[?????? 1?o?C?g???f?[?^?? 0?`255 ???}?b?v?????????????B
      Specified by:
      read in class InputStream
      Returns:
      ?????o?????? 1?o?C?g???f?[?^???????B
      ???? EndOfStream???B????????????? -1???????B
      Throws:
      IOException - ???}???????????X?g???[???? ???o???G???[?????????????
    • read

      public int read(byte[] buffer) throws IOException
      ???}???????X?g???[?????? buffer?????????????? ?f?[?^???????????B
      ?}?????\?b?h?? buffer ?????????????f?[?^?????????????A EndOfStream?????B?????????u???b?N?????B
      Overrides:
      read in class InputStream
      Parameters:
      buffer - ???????????f?[?^???i?[???????????o?C?g?z??
      Returns:
      buffer ?????????????f?[?^?????o?C?g?????????B
      ???? EndOfStream???B????????????? -1???????B
      Throws:
      IOException - ???}???????????X?g???[???? ???o???G???[?????????????
    • read

      public int read(byte[] buffer, int index, int length) throws IOException
      ???}???????X?g???[?????? buffer ?? index ???w???????? ???u?? length ?o?C?g?f?[?^???????????B
      ?}?????\?b?h?? length ?o?C?g???????????A EndOfStream?????B?????????u???b?N?????B
      Overrides:
      read in class 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:
      IOException - ???}???????????X?g???[???? ???o???G???[?????????????
    • skip

      public long skip(long length) throws IOException
      ???}???????????X?g???[?????f?[?^?? length ?o?C?g???????????B
      ?}?????\?b?h?? length ?o?C?g???????????? EndOfStream ?????B?????????u???b?N?????B
      Overrides:
      skip in class InputStream
      Parameters:
      length - ???????????o?C?g???B
      Returns:
      ?????????????????????o?C?g???B
      Throws:
      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 InputStream
      Parameters:
      readLimit - ?}?[?N???u???????????E???o?C?g???B ?}???o?C?g?????L?????f?[?^?????? ?????????? reset()?????????????? ?\?????????B
    • reset

      public void reset() throws IOException
      ???}???????????X?g???[???????????????u???????? mark() ???\?b?h???????o???????????????u???????????B
      Overrides:
      reset in class InputStream
      Throws:
      IOException -
      (1) CachedInputStream ?? 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 InputStream
      Returns:
      ?X?g???[???? mark() ?? reset() ?? ?T?|?[?g?????????? true?B
      ?T?|?[?g??????????? false?B
    • available

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

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