test/java/io/File/SetLastModified.java

Print this page
rev 3565 : 7022624: use try-with-resources in java.io tests
Reviewed-by: XXX

*** 103,115 **** final long G = 1024L * 1024L * 1024L; final long MAX_POSITION = 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(); ot = f.lastModified(); System.out.format("check with file size: %d\n", f.length()); if (!f.setLastModified(nt)) throw new Exception("setLastModified failed on file: " + f); ck(f, nt, f.lastModified()); --- 103,115 ---- final long G = 1024L * 1024L * 1024L; final long MAX_POSITION = System.getProperty("os.name").startsWith("Windows") ? 0L : 3L*G; long pos = 0L; while (pos <= MAX_POSITION) { ! 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)) throw new Exception("setLastModified failed on file: " + f); ck(f, nt, f.lastModified());