-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileReader.java
More file actions
40 lines (36 loc) · 931 Bytes
/
FileReader.java
File metadata and controls
40 lines (36 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package cs3500.pa05.model;
import cs3500.pa05.model.json.WeekJson;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
/**
* Reads a .bujo file and converts it into a WeekJson
*/
public class FileReader {
private WeekJson weekJson;
private Path path;
/**
* Instantiates a FileReader
*
* @param path path of .bujo file
*/
public FileReader(Path path) {
this.path = path;
}
/**
* Reads the .bujo file and creates a WeekJson
* containing the file's data.
*
* @return WeekJson with data for the week GUI
*/
public WeekJson readBujo() {
String jsonString = "";
try {
jsonString = new String(Files.readAllBytes(this.path));
} catch (IOException e) {
System.err.println("Path not found");
}
this.weekJson = JsonUtils.deserializeJsonString(jsonString);
return this.weekJson;
}
}