mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-24 19:06:53 +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 {
|
||||
boolean append = true;
|
||||
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.close();
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user