Here you can find the source of touch(File file)
public static void touch(File file) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static void touch(File file) throws IOException { long timestamp = System.currentTimeMillis(); touch(file, timestamp);//from w ww .j ava 2 s . c om } private static void touch(File file, long timestamp) throws IOException { if (!file.exists()) { new FileOutputStream(file).close(); } if (!file.setLastModified(timestamp)) { throw new IOException("Could not set last modified for " + file.getName()); } } }