diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/FileHandlingSelectedBudget.java b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/FileHandlingSelectedBudget.java index 85e95294a1529503826b2e96767e529f9c3a0d83..067abebbd607d34f83fcf324b0daaf1118a9701e 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/FileHandlingSelectedBudget.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/FileHandlingSelectedBudget.java @@ -22,7 +22,7 @@ public class FileHandlingSelectedBudget { selectedBudgetFileType))) { return br.readLine(); } catch (IOException ioException) { - throw new IOException("File: CurrentFile.txt does not exist", ioException); + throw new IOException("File: SelectedBudget.current does not exist", ioException); } } @@ -36,6 +36,16 @@ public class FileHandlingSelectedBudget { } } + public static void clearSelectedBudget() throws IOException { + try (BufferedWriter bw = new BufferedWriter(new FileWriter(filePath + "SelectedBudget" + + selectedBudgetFileType))) { + bw.write(""); + System.out.println("Current file is: "); + } catch (IOException ex) { + throw new IOException("Error writing to file: " + "SelectedBudget.current"); + } + } + public static boolean isSelectedBudgetEmpty(String fileTitle) throws IOException { try (BufferedReader br = new BufferedReader(new FileReader(filePath + "SelectedBudget" + selectedBudgetFileType))) {