筆記一下
import java.io.*; string Path = "C:\floder1\floder2\"; File dir_file = new File(Path ); //確認資料夾是否建立 if (!dir_file.exists()) { dir_file.mkdirs();//包含子資料夾的建立 } File HeadFile = new File(Path+"temp.txt"); //準備儲存的檔案位置 FileOutputStream FileStream = new FileOutputStream(HeadFile); PrintWriter PrintWriter = new PrintWriter(FileStream); PrintWriter.println("我是第一行"); PrintWriter.flush(); PrintWriter.close(); FileStream.close();
output :