mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-02-03 05:27:44 +01:00
FileUtils:copyStringToFile: Try not to leak file.
This commit is contained in:
parent
8907757674
commit
758e9223d1
@ -97,15 +97,16 @@ public class FileUtils {
|
||||
* @param dst the file to write to
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void copyStringToFile(String string, File dst, String mode) throws IOException{
|
||||
BufferedWriter writer;
|
||||
if (Objects.equals(mode, "append")) {
|
||||
writer = new BufferedWriter(new FileWriter(dst, true));
|
||||
} else {
|
||||
writer = new BufferedWriter(new FileWriter(dst, false));
|
||||
}
|
||||
writer.write(string);
|
||||
writer.close();
|
||||
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));
|
||||
writer.write(string);
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user