| Real'sHowTo |
|
|
Custom Search
|
| Real'sHowTo |
|
|
Custom Search
|
import java.io.File;
public class FileUtils {
private FileUtils () {}
public static boolean touch(String file) {
return touch(new File(file));
}
public static boolean touch(File file) {
if (file.exists()) {
return file.setLastModified(System.currentTimeMillis());
}
return false;
}
public static void main(String args[]) throws Exception {
System.out.println(FileUtils.touch("C:/temp/java-x.pdf"));
System.out.println(FileUtils.touch(new File("C:/temp/Hello.class")));
System.out.println(FileUtils.touch(new File("C:/temp/missingfile.pdf")));
}
}
import org.apache.commons.io.FileUtils; ... FileUtils.touch(myFile)
Written and compiled by Réal Gagnon ©1998-2013
[ home ]