本帖最后由 六期刘健 于 2011-12-29 11:35 编辑
import java.io.*;
class MyBuff
{
private FileReader fr;
MyBuff(FileReader fr){
this.fr=fr;
}
public String MyreadLine()throws IOException
{
StringBuilder sb=new StringBuilder();
int i=0;
while((i=fr.read())!=-1){
if(i=='\r')
continue;
if(i=='\n')
return sb.toString();
else
sb.append((char)i);
}
return null;
}
public void Myclose()throws IOException
{
fr.close();
}
}
class MyBuffered
{
public static void main(String[] args) throws IOException
{
FileReader fr=new FileReader("ceshi.java");
MyBuff mb=new MyBuff(fr);
String s="";
while((s=mb.MyreadLine())!=null){
System.out.print(s);
}
}
}
哪里错了!!!出现异常 |
|