< prev index next >

src/java.base/share/classes/java/util/zip/CheckedInputStream.java

Print this page




  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.util.zip;
  27 
  28 import java.io.FilterInputStream;
  29 import java.io.InputStream;
  30 import java.io.IOException;
  31 
  32 /**
  33  * An input stream that also maintains a checksum of the data being read.
  34  * The checksum can then be used to verify the integrity of the input data.
  35  *
  36  * @see         Checksum
  37  * @author      David Connelly

  38  */
  39 public
  40 class CheckedInputStream extends FilterInputStream {
  41     private Checksum cksum;
  42 
  43     /**
  44      * Creates an input stream using the specified Checksum.
  45      * @param in the input stream
  46      * @param cksum the Checksum
  47      */
  48     public CheckedInputStream(InputStream in, Checksum cksum) {
  49         super(in);
  50         this.cksum = cksum;
  51     }
  52 
  53     /**
  54      * Reads a byte. Will block if no input is available.
  55      * @return the byte read, or -1 if the end of the stream is reached.
  56      * @exception IOException if an I/O error has occurred
  57      */




  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.util.zip;
  27 
  28 import java.io.FilterInputStream;
  29 import java.io.InputStream;
  30 import java.io.IOException;
  31 
  32 /**
  33  * An input stream that also maintains a checksum of the data being read.
  34  * The checksum can then be used to verify the integrity of the input data.
  35  *
  36  * @see         Checksum
  37  * @author      David Connelly
  38  * @since 1.1
  39  */
  40 public
  41 class CheckedInputStream extends FilterInputStream {
  42     private Checksum cksum;
  43 
  44     /**
  45      * Creates an input stream using the specified Checksum.
  46      * @param in the input stream
  47      * @param cksum the Checksum
  48      */
  49     public CheckedInputStream(InputStream in, Checksum cksum) {
  50         super(in);
  51         this.cksum = cksum;
  52     }
  53 
  54     /**
  55      * Reads a byte. Will block if no input is available.
  56      * @return the byte read, or -1 if the end of the stream is reached.
  57      * @exception IOException if an I/O error has occurred
  58      */


< prev index next >