P
PilotYid
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. 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.
Does anyone know if there is a way to update the modified time without
closing the file? I am running this on WinXP.
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());
modification date?
I have a RandomAccessFile that I am writing to, but the modified time
doesn't change when it is written 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.
Does anyone know if there is a way to update the modified time without
closing the file? I am running this on WinXP.
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());