0

To produce two diferent files to a ZipStream I am using two methods receiving an outputStream something like this:

private void produceFileA (OutputStream stream){
 final PrintStream printer = new PrintStream (stream);
   ......
}

private void produceFileB (OutputStream stream) {
 final PrintStream printer = new PrintStream (stream);
 .....

}  

client:

private void produceZip () {
 try (ZipOutputStream zipStream = new ....) {
 ...
 produceFileA (zipStream);
 ...
 produceFileB (zipStream);
....
}
}

both will receive the same ZipOutputStream so I dont see how I can close the PrintStream created here if produceFileA closes it the produceFileB will not work anymore since it will receive a closed stream.. it is ok if I let them unclosed after finishing the methods call? (the underlying zipStream is closed by the client of these methods)

I am trying to be sure my PrintStreams dont leak any resource.

assylias
  • 321,522
  • 82
  • 660
  • 783
rdim66
  • 1
  • 1

0 Answers0