This commit is contained in:
2022-11-11 15:04:02 +08:00
parent 0b041bad7b
commit 042f53e134
9 changed files with 103 additions and 6 deletions

View File

@@ -33,6 +33,24 @@ public class FileUtil {
}
}
}
/**
* 把字符串追加保存成文件
*/
public static void saveAddStringToFile(File dir, String content, String fileName) {
PrintWriter writer = null;
try {
FileOutputStream os = new FileOutputStream(new File(dir, fileName));
writer = new PrintWriter(os);
writer.append(content);
writer.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
if (writer != null) {
writer.close();
}
}
}
/**
* 从文件读取字符串