Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CRC32 check for zip

 
carlos sanchez
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, hope this is the right forum to post this. I'm transfering a file through a servlet, it's a zip file and I want to know if I can check the integrity of the zip before I try to send it (I'm extracting it from documentum) and when I've received it. Last part is easy I've just got to send the CRC string.
Is it possible to check before sending it (without opening it)?
Thanks
 
Billybob Marshall
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by carlos i sanchez:
...I want to know if I can check the integrity of the zip before I try to send it...

Why? Seems to me that "garbage in, garbage out" should apply.
 
carlos sanchez
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does to me, but I'm not the boss here!
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to check before sending it (without opening it)?
Depends what you mean by "without opening it". If you mean, without a human being double clicking on the file to open it, then yes. If you mean, without having some sort of process do something to read the contents of the file, then no. To see if the contents of the file are OK, something, somewhere, would need to look at the file.
Why? Seems to me that "garbage in, garbage out" should apply.
Well it may be useful to know at what point in the process it was garbage. If the client receives a bad file, was it bad to begin with, or is there some flaw in the client or servlet which corrupts the data?
To check integrity, I would probaby create a ZipFile and loop through all the entries, see if an exception is thrown. If you've got enough free time on the server, get the input stream for each entry and read the entire contents. If no error is thrown, the integrity is probably OK.
 
carlos sanchez
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Obviously I mean somebody clicking. I'm going to start working with this:
public class CheckedInputStream
extends FilterInputStream
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.
Might be the answer......I hope, thanks 2 u all, again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic