Here you can find the source of touch(File file)
public static void touch(File file) throws IOException
//package com.java2s; //it under the terms of the GNU Affero General Public License as published by import java.io.File; import java.io.IOException; public class Main { public static void touch(File file) throws IOException { touch(file, false);/*from ww w .ja va 2 s . co m*/ } public static void touch(File file, boolean recursive) throws IOException { boolean success = false; if (file.exists()) { success = file.setLastModified(System.currentTimeMillis()); } checkSuccess(success, "Cannot touch file " + file); } private static void checkSuccess(boolean success, String message) throws IOException { if (!success) { throw new IOException(message); } } }