• Post Reply Bookmark Topic Watch Topic
  • New Topic

CheckedInputStream - java.util.zip  RSS feed

 
Nijeesh Balan
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
As per jdk 1.4 documentation, Class CheckedInputStream is supposed to return
"An input stream that also maintains a checksum of the data being read. The checksum can then be used to verify the integrity of the input data."

I was expecting it to print the CheckSum value of the input file, rather it prints the value "0" always(irrespective of the i/p argument).
When i went thru the src code for CheckedInputStream, I noticed that the constructor does nothing other than assigning the passed in checksum value to it's instance variable.
Is this is an expected result? or am I missing something?
Please clarify.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CheckedInputStream extends FilterInputStream; the idea is that you read another stream through the CheckedInputStream, and then afterwards get the checksum for all the bytes that have been read. In this case, you haven't read any bytes yet; the checksum is zero.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!