try{
BufferedReader in4 =new BufferedReader(new StringReader(s2)); //把s2当作输入对象
PrintWriter out1 =new PrintWriter(new BufferedWriter(new FileWriter(\"F:epalon TestIO.out\")));
int lineCount = 1;
while((s = in4.readLine()) != null)
out1.println(lineCount + \":\" + s);
out1.close();
in4.close();
}
catch(EOFException ex){
System.out.println(\"End of stream\");
}
//5. 数据的存储和恢复
try{
DataOutputStream out2 = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(\"F:epalon Data.txt\")));
out2.writeDouble(3.1415926);
out2.writeChars(" Thas was pi:writeChars ");
out2.writeBytes( "Thas was pi:writeByte ");
out2.close();
DataInputStream in5 = new DataInputStream(new BufferedInputStream(new FileInputStream(\"F:epalon Data.txt\")));
BufferedReader in5br = new BufferedReader(new InputStreamReader(in5));
System.out.println(in5.readDouble());
System.out.println(in5br.readLine());
System.out.println(in5br.readLine());
}
catch(EOFException e){
System.out.println(\"End of stream\");
}