2

How can I set the last modified date of a file using TrueVFS? Because accordingly to the (manual) it should be as simple as

File entry = new TFile("archive.zip/dir/HälloWörld.txt");
entry.setLastModified(System.currentTimeMillis());

But this doesn't work for files, but if I do the same thing for a folder it works.

This is what I'm using

String NUMBER_FILE = "C:/333/ServerEAR.ear/1.txt";

String newLastModified = "11/12/1999 14:15:16";
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
long newDate = sdf.parse(newLastModified).getTime();

File entry = new TFile(NUMBER_FILE);
boolean result = entry.setLastModified(newDate);

Although the result is true the date isn't modified to the one I want

Gonçalo Cardoso
  • 2,253
  • 4
  • 34
  • 63
  • I'm having trouble trying to make this code compile, it can't find the import statements and the internet isn't much help, could you post the import statements for TFile? No matter what I do I just can't get it to compile – DreadHeadedDeveloper Oct 27 '14 at 19:37
  • You can download the required JAR's from https://truevfs.java.net/kick-start/maven.html or https://truevfs.java.net/kick-start/no-maven.html. The import is import net.java.truevfs.access.TFile; – Gonçalo Cardoso Oct 28 '14 at 09:58
  • Just found at that it can change the file date, but only in certain situations. Gonna try and find out exactly what they are... – Gonçalo Cardoso Oct 28 '14 at 12:16
  • Do post up an answer when you figure it out because now I'm curious! – DreadHeadedDeveloper Oct 28 '14 at 14:03

0 Answers0