Here you can find the source of touch(File file)
public static boolean touch(File file)
//package com.java2s; /*####################################################### * * Maintained by Gregor Santner, 2017- * https://gsantner.net//* w ww . ja v a 2 s . c o m*/ * * License: Apache 2.0 * https://github.com/gsantner/opoc/#licensing * https://www.apache.org/licenses/LICENSE-2.0 * #########################################################*/ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static boolean touch(File file) { try { if (!file.exists()) { new FileOutputStream(file).close(); } return file.setLastModified(System.currentTimeMillis()); } catch (IOException e) { return false; } } }