追加文件
(String fileName, String text)
| 97 | * 追加文件 |
| 98 | */ |
| 99 | public static void writeToFileAppend(String fileName, String text) { |
| 100 | FileWriter fw = null; |
| 101 | try { |
| 102 | //如果文件存在,则追加内容;如果文件不存在,则创建文件 |
| 103 | File f = new File(fileName); |
| 104 | fw = new FileWriter(f, false); |
| 105 | } catch (IOException e) { |
| 106 | e.printStackTrace(); |
| 107 | } |
| 108 | PrintWriter pw = new PrintWriter(fw); |
| 109 | pw.println(text); |
| 110 | pw.flush(); |
| 111 | try { |
| 112 | fw.flush(); |
| 113 | pw.close(); |
| 114 | fw.close(); |
| 115 | } catch (IOException e) { |
| 116 | e.printStackTrace(); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * 修改实体类 |