hey so i'm having trouble with trying to generate a txt file for an assignment. It's supposed to generate two files the first one is a .dat file and that one gets created perfectly fine. However the other one which is a .txt file is not here is the code i have
private static final String LOGFILE = "reminderlog.txt";
and then i also have
public void log(Reminder r) {
LocalDateTime local = LocalDateTime.from(
Instant.now().atZone(ZoneId.systemDefault()));
String msg = local.truncatedTo(ChronoUnit.MILLIS) +
":Reminder:" + r.getContact().getName();
System.out.println("Log File Path = " + Path.of(LOGFILE).toAbsolutePath()); // tells us the directory path.
try (BufferedWriter reminderlog = Files.newBufferedWriter(Path.of(LOGFILE),
StandardOpenOption.CREATE, StandardOpenOption.APPEND);) {
reminderlog.write(msg);
reminderlog.newLine();
reminderlog.close(); // Close the BufferedWriter
} catch (IOException e) {
System.err.println("LOG FAIL" + msg);
e.printStackTrace();
}
}```
idk if this code will be enough for someone to help me out but if you want me to send the full source code i can.