private static void writeToStreamAndClose(String[] lines,OutputStream outputStream){
  try (PrintStream writer=new PrintStream(outputStream)){
    for (    String line : lines) {
      writer.println(line);
    }
  }
 }

private static void writeToStreamAndClose ( String [ ] lines , OutputStream outputStream ) { try ( PrintStream writer = new PrintStream ( outputStream ) ) { for ( String line : lines ) { writer . println ( line ) ; } } }
helper that writes the given lines ( adding a newline in between ) to a stream , then closes the stream .
