集册 Java实例教程 这会将行的数组列表导出到文件中

这会将行的数组列表导出到文件中

欢马劈雪     最近更新时间:2020-01-02 10:19:05

452
这会将行的数组列表导出到文件
//n o w j a v a . c o m 提 供


//package com.nowjava;


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 {

    /**

     * 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) {
        
展开阅读全文