[求助]有很多人都想用的一个流
谁能写一个对象流的小例子
让我知道他是怎么读写的啊
import java.io.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Test03_1
{
static public void ReadData(String FileName) throws IOException
{
String Str="";
FileReader fr=null;
BufferedReader br=null;
try
{
fr = new FileReader(FileName);
br = new BufferedReader(fr);
String record = new String();
while ((record = br.readLine()) != null)
{
Str+=record+"\n";
}
}
catch (IOException e)
{
System.out.println("文件读失败!");
e.printStackTrace();
}
br.close();
fr.close();
System.out.println(Str);
return ;
}
public static void main(String[] args)
{
try
{
ReadData("d:\\1.txt");
//...
}
catch (IOException e)
{
//...
}
//catch(/....)
}
}