Write string to file with FileWriter
import java.io.FileWriter; class FileWriterDemo { public static void main(String args[]) throws Exception { FileWriter fw = new FileWriter(args[0]); // Write strings to the file for (int i = 0; i < 12; i++) { fw.write("Line " + i + "\n"); } // Close file writer fw.close(); } }