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("./duke.txt"), msg.getBytes());
}
}
来源:java把字符串写入文件里的简单方法分享-http://www.jb51.net/article/47842.htm
网友评论