1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-25 03:16:51 +01:00

FileUtils: refactor copyStringToFile

With the goal to hinder potential leak of file.
This commit is contained in:
Ganblejs 2024-03-20 22:13:53 +01:00 committed by José Rebelo
parent 758e9223d1
commit 57c0c4dfcb

View File

@ -100,13 +100,10 @@ public class FileUtils {
public static void copyStringToFile(String string, File dst, String mode) throws IOException { public static void copyStringToFile(String string, File dst, String mode) throws IOException {
boolean append = true; boolean append = true;
if (!Objects.equals(mode, "append")) append = false; if (!Objects.equals(mode, "append")) append = false;
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(dst, append)); try (BufferedWriter writer = new BufferedWriter(new FileWriter(dst, append))) {
writer.write(string); writer.write(string);
writer.close(); }
} catch (IOException e) {
throw e;
};
} }
/** /**