aspose file tools*
The moose likes I/O and Streams and the fly likes CRC32 check for zip Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "CRC32 check for zip" Watch "CRC32 check for zip" New topic
Author

CRC32 check for zip

carlos sanchez
Ranch Hand

Joined: Jan 29, 2003
Posts: 45
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


Don't ever let your computer know you're in a hurry! :nono:
Billybob Marshall
Ranch Hand

Joined: Jan 27, 2004
Posts: 202
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

Joined: Jan 29, 2003
Posts: 45
It does to me, but I'm not the boss here!
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
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.


"I'm not back." - Bill Harding, Twister
carlos sanchez
Ranch Hand

Joined: Jan 29, 2003
Posts: 45
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: CRC32 check for zip