Search code examples
javafiletouch

Simulate touch command with Java


I want to change modification timestamp of a binary file. What is the best way for doing this?

Would opening and closing the file be a good option? (I require a solution where the modification of the timestamp will be changed on every platform and JVM).


Solution

  • The File class has a setLastModified method. That is what ANT does.