MCPcopy Create free account
hub / github.com/Hello-hao/Tbed / contentToTxt

Method contentToTxt

src/main/java/cn/hellohao/utils/FirstRun.java:208–233  ·  view source on GitHub ↗
(String filePath, String content)

Source from the content-addressed store, hash-verified

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}

Callers 1

afterPropertiesSetMethod · 0.95

Calls 2

existsMethod · 0.80
printMethod · 0.80

Tested by

no test coverage detected