private void writeFile(String path, String content) { File file = null; FileOutputStream fos = null; try { file = new File(path); if (!file.exists()) { file.createNewFile(); } // append if true, then bytes will be written to the end of the file rather than the beginning fos = new FileOutputStream(file, true); fos.write(content.getBytes()); } catch (IOException e) { e.printStackTrace(); } finally { try { if (fos != null) { fos.close(); } } catch (IOException e) { e.printStackTrace(); } } }
Java写文件
猜你喜欢
转载自516456267.iteye.com/blog/2254077
今日推荐
周排行