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?
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.