private static void write(Collection<String> src,File out) throws IOException {
  try (Writer writer=new BufferedWriter(new FileWriter(out))){
    for (    String line : src)     writer.write(line + '\n');
  }
 }

private static void write ( Collection < String > src , File out ) throws IOException { try ( Writer writer = new BufferedWriter ( new FileWriter ( out ) ) ) { for ( String line : src ) writer . write ( line + '\n' ) ; } }
write source code to file .
