Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

gunzipping the file more than once at the same time

 
Vani Bhatia
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic