Java examples for File Path IO:Text File
This exports the array list of lines to a file
//package com.java2s; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; public class Main { /**/*from w w w . j a v a 2 s.c o m*/ * This exports the array list of lines to a file * @param lines the lines of the text file * @param dataFile the file to put the lines into */ public static void exportLinesToFile(ArrayList<String> lines, Path dataFile) { try { Files.write(dataFile, lines, StandardCharsets.UTF_8); } catch (IOException ex) { System.out.println("Error writing lines to file: " + ex); } } }