Reformatting try-with-resources
@@ -11,7 +11,8 @@ public class MyResourceLoader {
private void loadFileWithReader() throws IOException {
- try (FileReader fileReader = new FileReader("src/main/resources/input.txt"); BufferedReader reader = new BufferedReader(fileReader)) {
+ try (FileReader fileReader = new FileReader("src/main/resources/input.txt");
+ BufferedReader reader = new BufferedReader(fileReader)) {
String contents = reader.lines()
.collect(Collectors.joining(System.lineSeparator()));
System.out.println(contents);
@@ -21,7 +22,8 @@ public class MyResourceLoader {
private void loadFileAsResource() throws IOException {
- try (InputStream inputStream = getClass().getResourceAsStream("/input.txt"); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
+ try (InputStream inputStream = getClass().getResourceAsStream("/input.txt");
+ BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
String contents = reader.lines()
.collect(Collectors.joining(System.lineSeparator()));
System.out.println(contents);
