- FileReader reader = new FileReader(path);
- BufferedReader bf = new BufferedReader(reader);
- bf.readLine(); // Skip version
- String json = bf.lines().dropWhile(s -> s.length() == 0 || s.charAt(0) != '{').reduce("", (x, y) -> x.concat(y));
- T params = parser.fromJson(json, type);
- reader.close();
- return params;
+ try (FileReader reader = new FileReader(path); BufferedReader bf = new BufferedReader(reader))
+ {
+ String json = bf.lines().dropWhile(s -> s.length() == 0 || s.charAt(0) != '{').reduce("", (x, y) -> x.concat(y));
+ T params = parser.fromJson(json, type);
+ return params;
+ }