创建文件并使用if语句检查创建是否成功
//from 时代Java import java.io.File; import java.io.IOException; public class Main { public static void main(String[] arg) throws IOException { File f = new File("c:/myfile.txt"); if (f.createNewFile()) System.out.println("File created."); else System.out.println("File could not be created."); } }