import java.util.*;
public class InputTest {
public static void main(String args[]){
Scanner in=new Scanner(new File("c:\\test.txt"));
System.out.println("What is your name?");
String name=in.nextLine();
System.out.println("How old are you?");
int age=in.nextInt();
++age;
System.out.println("Hello, "+name+".Next year,you'll be "+age);
System.out.printf("%tc",new Date());}
}
然后提示这个错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problem: Unhandled exception type FileNotFoundException
at InputTest.main(InputTest.java:10)
请大神们看看吧~
public class InputTest {
public static void main(String args[]){
Scanner in=new Scanner(new File("c:\\test.txt"));
System.out.println("What is your name?");
String name=in.nextLine();
System.out.println("How old are you?");
int age=in.nextInt();
++age;
System.out.println("Hello, "+name+".Next year,you'll be "+age);
System.out.printf("%tc",new Date());}
}
然后提示这个错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problem: Unhandled exception type FileNotFoundException
at InputTest.main(InputTest.java:10)
请大神们看看吧~