我写的Java学生成绩管理系统源代码(9) name +" , "+ sex +" , "+ String.valueOf(mark);//把所有的数据用" , "隔开然后在连起来放进字符串all }catch (IOException e){} catch (NumberFormatException e){} return all;//返回字符串all } public void addData(String str)//增加数据的方法 throws IOException { String s1 ="",s2="" ,s3= ""; File file = new File("data.txt"); if (file.exists())//如果文件data.txt存在 { try{ BufferedReader in = new BufferedReader( new FileReader("data.txt")); while ((s1=in.readLine())!=null) s2+=s1+"\n";//把文件中的每行数据全部放进一个字符串s2 s2+=str+"\n"; //再把s2于形参str相连放进s2