我想应该是你写的MyReader类没有继承Reader类并重写Reader中的read()方法
class MyReader entends Reader
{
private FileReader r;
MyReader(FileReader r)
{
this.r = r;
}
public String MyReadeLine()throws IOException
{
StringBuilder sb = new StringBuilder();
int len = 0;
while((len=r.read())!=-1);
{
if(len=='\r')
continue;
if(len=='\n')
return sb.toString();
else
sb.append((char)len);
}
if(sb.length()!=0)
return sb.toString();
return null;
}
public int read(char[] cbuf, int off, int len) throws IOException
{
return r.read(cbuf,off,len) ;
}
public void myclose()throws IOException
{
r.close();
}
}
主函数我就没写了
|