Simulate touch command with Java

sinuhepop picture sinuhepop · Sep 10, 2009 · Viewed 35.9k times · Source

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).

Answer

Yishai picture Yishai · Sep 10, 2009

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