Skip to content

Commit

Permalink
Fixed IOException error in JAR file
Browse files Browse the repository at this point in the history
  • Loading branch information
rgonslayer committed Sep 19, 2022
1 parent 66b954a commit 5f58e4c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions data/taskList.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
T | 0 | read
D | 0 | return book | 2022-10-10
D | 0 | return book | 2022-10-10
E | 0 | project meeting | 2022-10-10
T | 0 | gym
T | 0 | read book
7 changes: 5 additions & 2 deletions src/main/java/jarvis/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public Storage(String filePath) {
* @throws IOException if error occurs when reading file.
*/
public List<Task> load() throws IOException {
File myFile = new File(filePath);
File myFile = new File(System. getProperty("user. dir") + filePath);
List<Task> taskList = new ArrayList<>();
if (!myFile.createNewFile()) {
Scanner sc = new Scanner(myFile);
Expand Down Expand Up @@ -61,7 +61,10 @@ public List<Task> load() throws IOException {
* @throws IOException if error occurs when writing to data file.
*/
public void write(TaskList tasks) throws IOException {
File myFile = new File(filePath);
File myFile = new File(System. getProperty("user. dir") + filePath);
if (!myFile.getParentFile().exists()) {
myFile.getParentFile().mkdirs();
}
myFile.createNewFile();
FileWriter myWriter = new FileWriter(myFile);
for (int i = 0; i < tasks.getList().size(); i++) {
Expand Down

0 comments on commit 5f58e4c

Please sign in to comment.