private void writeLine(){ File file = new File("/storage/self/primary/360Log/replugin/aaaa_test.txt"); FileOutputStream fos = null; try { //不存在,创建 存在 在末尾追加 if (!file.exists()) { file.createNewFile(); fos = new FileOutputStream(file); } else { fos = new FileOutputStream(file, true); } OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8"); osw.write("no change line"); osw.write("\r\n"); osw.write("change line"); osw.close(); } catch (Exception e) { e.printStackTrace(); } }
向文件中添加数据
最新推荐文章于 2021-12-09 15:25:20 发布