jdk/test/java/io/File/SetLastModified.java
changeset 8559 826c03991926
parent 5506 202f599c92aa
child 9035 1255eb81cc2f
equal deleted inserted replaced
8558:e51c07113d09 8559:826c03991926
   103         final long G = 1024L * 1024L * 1024L;
   103         final long G = 1024L * 1024L * 1024L;
   104         final long MAX_POSITION =
   104         final long MAX_POSITION =
   105             System.getProperty("os.name").startsWith("Windows") ? 0L : 3L*G;
   105             System.getProperty("os.name").startsWith("Windows") ? 0L : 3L*G;
   106         long pos = 0L;
   106         long pos = 0L;
   107         while (pos <= MAX_POSITION) {
   107         while (pos <= MAX_POSITION) {
   108             FileChannel fc = new FileOutputStream(f).getChannel();
   108             try (FileChannel fc = new FileOutputStream(f).getChannel()) {
   109             fc.position(pos).write(ByteBuffer.wrap("x".getBytes()));
   109                 fc.position(pos).write(ByteBuffer.wrap("x".getBytes()));
   110             fc.close();
   110             }
   111             ot = f.lastModified();
   111             ot = f.lastModified();
   112             System.out.format("check with file size: %d\n", f.length());
   112             System.out.format("check with file size: %d\n", f.length());
   113             if (!f.setLastModified(nt))
   113             if (!f.setLastModified(nt))
   114                 throw new Exception("setLastModified failed on file: " + f);
   114                 throw new Exception("setLastModified failed on file: " + f);
   115             ck(f, nt, f.lastModified());
   115             ck(f, nt, f.lastModified());