找不到错误呀,快来帮忙,谢谢大家!

yunshiyu 2003-01-27 01:31:48
import java.io.*;
public class BufferDemo{
public static void main(String args[]){
int start = 0;
int finish = 255;
if (args.length>1){
start = Integer.parseInt(args[0]);
finish = Integer.parseInt(args[1]);
} else if (args.length>0)
start = Integer.parseInt(args[0]);
ArgStream as = new ArgStream(start,finish);
System.out.println("\nWrite: ");
boolean success = as.writeStream();
System.out.println("\nReading: ");
boolean readSuccess = as.readStream();
}
}
class ArgStream{
int start = 0;
int finish = 255;
ArgStream(int st,int fin){
start = st;
finish = fin;
}
boolean writeStream(){
try{
FileOutputStream File = new FileOutputStream("number.dat");
BufferedOutputStream buff = new BufferedOutputStream(File);
for (int i=start;i<=finish;i++){
buff.write(i);
System.out.println(" "+i);
}
buff.close();
return true;
} catch(IOException e){
System.out.println("Exception: "+e.getMessage());
return false;
}
}
boolean readSuccess(){
try{
FileInputStream File = new FileInputStream("number.dat");
BufferedInputStream buff = new BufferedInputStream(File);
int in = 0;
do {
in = buff.read();
if (in!=-1)
System.out.print(" "+in);
}while(in!=-1);
buff.close();
return true;
} catch(IOException e){
System.out.println("Exception: "+e.getMessage());
return false;
}
}
}
不知道错在那里,提示是15行有错。
...全文
65 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yunshiyu 2003-01-27
  • 打赏
  • 举报
回复
找到错误了
谢谢大家
bluesmile979 2003-01-27
  • 打赏
  • 举报
回复
boolean readSuccess = as.readStream();
你是要写boolean readSuccess = as.readSucess();吧?

根本就没有readStream这个方法啊。
Norwaywoods 2003-01-27
  • 打赏
  • 举报
回复
只有一行呀!就是
boolean readSuccess = as.readStream();
把它注释掉或者,实现这个readStream()方法就可以了。

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧