List of utility methods to do File Touch
void | touch(File file) touch if (file.exists()) { return; try { boolean success = file.createNewFile(); if (!success) { throw new RuntimeException("can't create file. [" + file + "]"); } catch (IOException e) { throw new RuntimeException("can't create file. [" + file + "]"); |
boolean | touch(File file) touch try { if (!file.exists()) { new FileOutputStream(file).close(); return file.setLastModified(System.currentTimeMillis()); } catch (IOException e) { return false; |
void | touch(File file) Implements the same behaviour as the "touch" utility on Unix. if (!file.exists()) { OutputStream out = new FileOutputStream(file); closeQuietly(out); file.setLastModified(System.currentTimeMillis()); |
void | touch(File file) Updates a file's last-modified timestamp. if (file.exists()) file.setLastModified(System.currentTimeMillis()); else { File parent = file.getParentFile(); if (parent != null) parent.mkdirs(); file.createNewFile(); |
void | touch(File file) touch file = file.getAbsoluteFile(); FileOutputStream out = new FileOutputStream(file); out.close(); if (!file.exists()) { throw new IOException("touch failed: " + file); |
void | touch(File file) touch if (!file.exists())
createEmpty(file);
unguardedTouch(file);
|
void | touch(File file) touch long currentTime = System.currentTimeMillis(); if (!file.exists()) { try { if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } catch (Exception e) { System.err.println("Create file failed!"); ... |
void | touch(File file) Touch (update the modification time) the given file. file.setLastModified(System.currentTimeMillis()); |
boolean | touch(File file, boolean createIfNeeded) touch if (file.exists()) { if (!file.setLastModified(System.currentTimeMillis())) { return false; } else if (createIfNeeded) { try { return file.createNewFile(); } catch (IOException e) { ... |
void | touch(FileFilter filter, File root, boolean recurse) touch if (filter.accept(root)) root.setLastModified(new Date().getTime()); if (recurse && root.isDirectory()) { File[] children = root.listFiles(); if (children != null) { for (int i = 0; i < children.length; i++) { touch(filter, children[i], recurse); |