创建新的空文件
import java.io.*; public class Main { /** * NowJava.com - 时代Java 提 供 **/ public static void main(String[] args) { File file = new File("C://demo.txt"); boolean blnCreated = false; try { blnCreated = file.createNewFile(); } catch(IOException ioe) { System.out.println("Error while creating a new empty file :" + ioe); } System.out.println("Was file " + file.getPath() + " created ? : " + blnCreated); } } /** n o w j a v a . c o m - 时代Java **/