import java.io.File;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str1 = sc.next(); //键盘输入 ioTest\test.txt
String str2 = "ioTest\test.txt";
File file = new File(str1);
File file2 = new File(str2);
System.out.println(file.exists()); //true
System.out.println(file2.exists()); //false
}
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |