資料寫入檔案
/** * 產檔 * @param filePathLocal 路徑 * @param fileName 檔名 * @param str內容 * @throws IOException */ public void mkFile(String filePathLocal, String fileName, String str) throws IOException { File file = new File(filePathLocal); if (!file.isDirectory()) { file.mkdirs(); //資料夾權限 file.setReadable(true, false); file.setExecutable(true, false); file.setWritable(true, false); } Path localFile = Paths.get(filePathLocal, fileName); BufferedWriter writer = Files.newBufferedWriter(localFile, StandardCharsets.UTF_8); writer.write(xml); writer.close(); }
文章標籤
全站熱搜