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; import java.io.IOException; public class Main { public static void touch(File file) { if (file.exists()) { return; }//from w ww . ja va2s.c o m 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 + "]"); } } }