import java.io.*; String filePath = "/data/account.txt"; String conent = vars.get("account"); BufferedWriter out = null; try { File file = new File(filePath); File fileParent = file.getParentFile(); if (!fileParent.exists()) { fileParent.mkdirs(); } file.createNewFile(); out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true))); out.write(conent + "\r\n"); } catch (Exception e) { e.printStackTrace(); } finally { try { out.close(); } catch (IOException e) { e.printStackTrace(); } }
原文地址:https://www.cnblogs.com/linbo3168/p/11073387.html
时间: 2024-11-05 17:29:13