wood burning stoves*
The moose likes I/O and Streams and the fly likes gunzipping the file more than once at the same time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "gunzipping the file more than once at the same time" Watch "gunzipping the file more than once at the same time" New topic
Author

gunzipping the file more than once at the same time

Vani Bhatia
Greenhorn

Joined: Nov 25, 2009
Posts: 7
Hello,

Iam new to Java programming. I want to know if a gzipped file can be gunzipped simultaneously more than once using GZIPInputStream and FileOutputStream classes. For instance, I have a file gzippedFileName.gz. I want to gunzip it into filename1 , filename 2,filename3 etc
at the same time(by using different threads to access it,may be). Is it possible to do like this?

Thanks
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

Although I don't get why you would want to do this (as you would get identical files), it most certainly is possible. However, I wouldn't use a thread for this; you would read the entire file over and over. Instead, use a special OutputStream subclass that writes to multiple other output streams as well. I've given an example for a Writer subclass here, although that uses only two streams. You can modify it to store an OutputStream[] or List<OutputStream>; each method then executes in a loop. E.g.:
With this class you can now simply read the file once, then copy to an instance of this class. It will take care of writing to all its backing output streams.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: gunzipping the file more than once at the same time
 
Similar Threads
IllegalThreadStateException
J2ee Training
Exception Handing
how to read from given line number
multiple fileupload