Here you can find the source of touch(File file)
public static void touch(File file)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { public static void touch(File file) { long currentTime = System.currentTimeMillis(); if (!file.exists()) { try { if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); }/* w ww. j a v a 2s . com*/ } catch (Exception e) { System.err.println("Create file failed!"); e.printStackTrace(); } } boolean result = file.setLastModified(currentTime); if (!result) { System.err.println("touch failed: " + file.getName()); } } public static void touch(String fileName) { File file = new File(fileName); touch(file); } public static void touch(File[] files) { for (int i = 0; i < files.length; i++) { touch(files[i]); } } public static void touch(String[] fileNames) { File[] files = new File[fileNames.length]; for (int i = 0; i < fileNames.length; i++) { files[i] = new File(fileNames[i]); } touch(files); } }