Here you can find the source of touch(String name)
public static File touch(String name) throws IOException
//package com.java2s; /*//from w w w .j a v a 2 s .com * Copyright 2013 Qunar.com All right reserved. This software is the confidential and proprietary information of * Qunar.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only * in accordance with the terms of the license agreement you entered into with Qunar.com. */ import com.google.common.io.Files; import java.io.File; import java.io.IOException; public class Main { public static File touch(String name) throws IOException { String tmpdir = System.getProperty("java.io.tmpdir"); File tmpfile = new File(tmpdir, name); Files.touch(tmpfile); return tmpfile; } }