Java Code Reorder Medium +20 XP
Try-With-Resources
Arrange the try-with-resources pattern.
Click lines in the correct order
Available lines4 left
Your order
Click lines above to build your solution.
Show answer and explanation
Answer: try (BufferedReader br = new BufferedReader(new FileReader("file.txt"))) {
String line = br.readLine();
System.out.println(line);
}
try-with-resources auto-closes the resource. Declare in try(), then use inside the block.
Hint: Resource declaration goes in the try parentheses.
What this challenge tests
Code Reorder in Java: try-with-resources, io.