String fileName = dir + File.separator + date + File.separator + (file.list().length + 1) + ".txt"; File file = new File(fileName); BufferedWriter writer = null; FileOutputStream writerStream = new FileOutputStream(file); writer = new BufferedWriter(new OutputStreamWriter(writerStream, "UTF-8")); StringBuilder strBuild = new StringBuilder(); writer.write(strBuild.toString());
注意上面的代碼最好放在catch中,而後在finally中添加ui
writer.flush(); writer.close();
參考連接:https://blog.csdn.net/dunceiam/article/details/43190609spa