1 7 8 package java.util.zip; 9 10 import java.io.FilterOutputStream ; 11 import java.io.OutputStream ; 12 import java.io.IOException ; 13 14 23 public 24 class CheckedOutputStream extends FilterOutputStream { 25 private Checksum cksum; 26 27 32 public CheckedOutputStream(OutputStream out, Checksum cksum) { 33 super(out); 34 this.cksum = cksum; 35 } 36 37 42 public void write(int b) throws IOException { 43 out.write(b); 44 cksum.update(b); 45 } 46 47 55 public void write(byte[] b, int off, int len) throws IOException { 56 out.write(b, off, len); 57 cksum.update(b, off, len); 58 } 59 60 64 public Checksum getChecksum() { 65 return cksum; 66 } 67 } 68 | Popular Tags |