Java List读取到.txt当中

package com.levizhao.filter;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Demo03 {
    public static void main(String[] args) throws IOException {
        Path out = Paths.get("output.txt");
        List<String> arrayList = new ArrayList<>( Arrays.asList ( "a" , "b" , "c" ) );
        Files.write(out,arrayList, Charset.defaultCharset());
    }
}
posted @ 2021-05-07 17:04  withLevi  阅读(147)  评论(0编辑  收藏  举报