使用File对象检查文件是否存在
import java.io.File; public class Main {/**来自 N o w J a v a . c o m - 时代Java**/ public static void main(String[] arg) { File f = new File("c:/myfile.txt"); if (!f.exists()) System.out.println("The input file does not exist!"); } }
import java.io.File; public class Main {/**来自 N o w J a v a . c o m - 时代Java**/ public static void main(String[] arg) { File f = new File("c:/myfile.txt"); if (!f.exists()) System.out.println("The input file does not exist!"); } }