- Employee[] staff=new Employee[3];
- staff[0]=new Employee("Jack",20000,1987,9,10);
- staff[1]=new Employee("Lily",13000,1991,2,19);
- staff[2]=new Employee("John",30000,1985,4,13);
- PrintWriter out=new PrintWriter("emlpoyee.txt");
- wirteData(staff,out);
- out.close();
- <font color="#ff0000"> Scanner in=new Scanner(new FileReader("employee.txt"));</font>
- Employee[] newStaff=readData(in);
- in.close();
- for(Employee e:newStaff)
- {
- System.out.println(e);
- }
复制代码 我首先在文件里写入了一些数据,然后准备利用Scanner扫描并获取文件中的内容,可是出现了FileNotFound的异常,可是这个文件明明是存在的啊
请大虾们指示。
|