jdk7,一行代码写内容到文件

来源 http://www.adam-bien.com/roller/abien/entry/java_7_writing_a_string

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

public class StringToFile {
    public static void main(String[] args) throws IOException {
        String msg = "hello";
        Files.write(Paths.get("F:/test.txt"), msg.getBytes());
    }
}



jdk真的是越来越强大了啊

你可能感兴趣的:(JDK7)