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:
parent
758e9223d1
commit
57c0c4dfcb
@ -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;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user