7022624: use try-with-resources in java.io tests
Reviewed-by: alanb
diff --git a/test/java/io/File/SetLastModified.java b/test/java/io/File/SetLastModified.java
index 3ca72c9..fada781 100644
--- a/test/java/io/File/SetLastModified.java
+++ b/test/java/io/File/SetLastModified.java
@@ -105,9 +105,9 @@
System.getProperty("os.name").startsWith("Windows") ? 0L : 3L*G;
long pos = 0L;
while (pos <= MAX_POSITION) {
- FileChannel fc = new FileOutputStream(f).getChannel();
- fc.position(pos).write(ByteBuffer.wrap("x".getBytes()));
- fc.close();
+ try (FileChannel fc = new FileOutputStream(f).getChannel()) {
+ fc.position(pos).write(ByteBuffer.wrap("x".getBytes()));
+ }
ot = f.lastModified();
System.out.format("check with file size: %d\n", f.length());
if (!f.setLastModified(nt))