我写的Java学生成绩管理系统源代码(11) while ((s3=in2.readLine())!= null) { out.println(s3); } out.close(); //System.out.println("write data true."); }catch (IOException e){} }else{ System.err.println("File \"data\" Missing!"); } } public void clearData()//清除data.txt的所有数据的方法 throws IOException { File file = new File("data.txt"); if(file.exists())//如果文件在 { try{ PrintWriter out = new PrintWriter( new BufferedWriter( new FileWriter(file))); out.print("");//在文件data.txt里写进一个空字符,所以清除了原来的内容