這個示例可以很簡單的把字符串寫入到文件,大家可以試試喲,這是跟一個外國朋友學(xué)的代碼,大家可以學(xué)習(xí)一下了
public class StringToFile {
public static void main(String[] args) throws IOException {
String msg = "hello";
Files.write(Paths.get("./duke.txt"), msg.getBytes());
}
}
新聞熱點
疑難解答