List of utility methods to do File Touch
boolean | touch(String fileName) touch try { File file = new File(fileName); if (file.exists() == false) { file.createNewFile(); } else { file.setLastModified(System.currentTimeMillis()); } catch (Throwable t) { ... |
boolean | touch(String filePath) Creates a blank file or updates its last modified date. File f = new File(filePath); FileOutputStream fos = new FileOutputStream(f, true); fos.close(); return true; |
File | touch(String fullFilePath) touch if (fullFilePath == null) { return null; File file = new File(fullFilePath); file.getParentFile().mkdirs(); if (!file.exists()) file.createNewFile(); return file; ... |
File | touch(String name) touch String tmpdir = System.getProperty("java.io.tmpdir"); File tmpfile = new File(tmpdir, name); Files.touch(tmpfile); return tmpfile; |
void | touchDir(String filePath) touch Dir File file = new File(filePath); if (!file.exists()) { file.mkdir(); |
void | touchExisting(File file) touch Existing if (file.exists())
unguardedTouch(file);
|
File | touchFile(File directory, String name) touch File File newfile = new File(directory.getAbsolutePath() + File.separator + name); touchFile(newfile); return newfile; |
void | touchFile(File file) Update last modified time of a given file to the current time long timestamp = System.currentTimeMillis(); if (!file.setLastModified(timestamp)) { System.err.println("Last Modified Time Update Failed"); |
void | touchFile(File file) Create an empty touch. FileOutputStream s = new FileOutputStream(file); try { s.write(file.toString().getBytes()); } finally { s.close(); |
void | touchFile(String target) touch File long now = new Date().getTime(); new File(target).setLastModified(now); |