(String filePath, String content)
| 206 | } |
| 207 | |
| 208 | public static void contentToTxt(String filePath, String content) { |
| 209 | // String str = new String(); //原有txt内容 |
| 210 | String s1 = new String();//内容更新 |
| 211 | try { |
| 212 | File f = new File(filePath); |
| 213 | if (f.exists()) { |
| 214 | System.out.print("文件存在"); |
| 215 | } else { |
| 216 | System.out.print("文件不存在"); |
| 217 | // f.createNewFile();// 不存在则创建 |
| 218 | FileUtil.createTempFile(f); |
| 219 | } |
| 220 | // BufferedReader input = new BufferedReader(new FileReader(f)); |
| 221 | // while ((str = input.readLine()) != null) { |
| 222 | // s1 += str + "\n"; |
| 223 | // } |
| 224 | // input.close(); |
| 225 | s1 += content + "\n"; |
| 226 | BufferedWriter output = new BufferedWriter(new FileWriter(f)); |
| 227 | output.write(s1); |
| 228 | output.close(); |
| 229 | } catch (Exception e) { |
| 230 | e.printStackTrace(); |
| 231 | |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | } |
no test coverage detected