/*** * 文件追加写入字符串 * * @param name 字符串 * * @param path txt文本地址 * */ public void fileWrite(String name, String path) { FileWriter fw = null; try { // 如果文件存在,则追加内容;如果文件不存在,则创建文件 File f = new File(path); fw = new FileWriter(f, true); } catch (IOException e) { e.printStackTrace(); } PrintWriter pw = new PrintWriter(fw); pw.write(name + "\r\n"); // pw.println("追加内容"); pw.flush(); try { fw.flush(); pw.close(); fw.close(); } catch (IOException e) { e.printStackTrace(); } }
字符串追加写入txt文本
猜你喜欢
转载自blog.csdn.net/weixin_39249630/article/details/80702534
今日推荐
周排行