1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 12:56:49 +01:00

Bangle.js: use FileUtils to read/write files

This commit is contained in:
Ganblejs 2024-02-16 22:59:45 +01:00 committed by José Rebelo
parent cba2cf38f6
commit c572cae161

View File

@ -1221,14 +1221,10 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
File outputFileLogID = new File(dir, filenameLogID); File outputFileLogID = new File(dir, filenameLogID);
LOG.warn("Writing log to " + outputFile.toString()); LOG.warn("Writing log to " + outputFile.toString());
try { try {
BufferedWriter writer = new BufferedWriter(new FileWriter(outputFile, true)); FileUtils.copyStringToFile(line,outputFile,"append");
writer.write(line);
writer.close();
//GB.toast(getContext(), "Log written to " + filename, Toast.LENGTH_LONG, GB.INFO); //GB.toast(getContext(), "Log written to " + filename, Toast.LENGTH_LONG, GB.INFO);
BufferedWriter writerLogID = new BufferedWriter(new FileWriter(outputFileLogID)); FileUtils.copyStringToFile(log,outputFileLogID,"");
writerLogID.write(log);
writerLogID.close();
//GB.toast(getContext(), "Log ID " + log + " written to " + filenameLogID, Toast.LENGTH_LONG, GB.INFO); //GB.toast(getContext(), "Log ID " + log + " written to " + filenameLogID, Toast.LENGTH_LONG, GB.INFO);
} catch (IOException e) { } catch (IOException e) {
LOG.warn("Could not write to file", e); LOG.warn("Could not write to file", e);
@ -1953,12 +1949,9 @@ public class BangleJSDeviceSupport extends AbstractBTLEDeviceSupport {
} }
String filename = "latestFetchedRecorderLog.txt"; String filename = "latestFetchedRecorderLog.txt";
File inputFile = new File(dir, filename); File inputFile = new File(dir, filename);
BufferedReader reader;
String lastSyncedID = ""; String lastSyncedID = "";
try { try {
reader = new BufferedReader(new FileReader(inputFile)); lastSyncedID = FileUtils.getStringFromFile(inputFile);
lastSyncedID = String.valueOf(reader.readLine());
reader.close();
} catch (IOException ignored) { } catch (IOException ignored) {
} }
//lastSyncedID = "20230706x"; // DEBUGGING //lastSyncedID = "20230706x"; // DEBUGGING