Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6357599

File.setLastModified(long) does not update 'last modified' time (win)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 1.4.2
    • core-libs
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.4.2_06"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)
      Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Does a file have to be closed to use setLastModified() to change its modification date?

      I have a RandomAccessFile that I am writing to, but the modified time doesn't change when it is written to (is it supposed to?). I would like use setLastModified() to update the time, but it returns false unless I close the RandomAccessFile first. For example, the code below only works if I uncomment the close() below.
      I am running this on WinXP, and it seems to work fine on Linux.

      File file = new File("c:\\work\\", "FILETEST.txt");
      file.createNewFile();
      RandomAccessFile raf = new RandomAccessFile(file, "rw");
      //raf.close();
      System.out.println("Before=" + file.lastModified());
      Thread.sleep(1000);
      System.out.println(file.setLastModified(System.currentTimeMillis()));
      System.out.println("After=" + file.lastModified());



      REPRODUCIBILITY :
      This bug can be reproduced always.

            alanb Alan Bateman
            jssunw Jitender S (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: