输入输出问题!!!!

东北小妞 2009-09-25 07:38:12
package bittable;
import java.io.*;


public class BinaryFile {
public static byte[] read(File file) throws IOException{
BufferedInputStream bf=new BufferedInputStream(new FileInputStream(file));
try{
byte[] data=new byte[bf.available()];
bf.read(data);
return data;
}finally{
bf.close();
}
}
public static byte[]
read(String file)throws IOException{
return read(new File(file).getAbsoluteFile());
}
public static void main(String[] args) {
try{
BinaryFile b=new BinaryFile();

byte[] bb=b.read("chess.dat");
}catch(IOException e){
throw new RuntimeException(e);
}

System.out.println();
}

}
高手看看,bb为什么赋不了值呀????
...全文
81 5 打赏 收藏 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
东北小妞 2009-09-25
  • 打赏
  • 举报
回复
哦,应该是eclipse 的问题,这回出现了,我又糊涂了
东北小妞 2009-09-25
  • 打赏
  • 举报
回复
byte[] bb=b.read("chess.dat");
System.out.println(new String(bb));
我的也能打印出来,在主程序的参数列表中bb看不到值,我用eclipse,我糊涂呀
tiaopizhu001 2009-09-25
  • 打赏
  • 举报
回复
不清楚
东北小妞 2009-09-25
  • 打赏
  • 举报
回复
我的文件是二进制文件,都是数字,而且data变量有值,到了但是bb就是没有值,为什么?
loveofmylife 2009-09-25
  • 打赏
  • 举报
回复

import java.io.*;


public class BinaryFile {
public static byte[] read(File file) throws IOException{
BufferedInputStream bf=new BufferedInputStream(new FileInputStream(file));
try{
byte[] data=new byte[bf.available()];
bf.read(data);
return data;
}finally{
bf.close();
}
}
public static byte[]
read(String file)throws IOException{
return read(new File(file).getAbsoluteFile());
}
public static void main(String[] args) {
try{
BinaryFile b=new BinaryFile();

byte[] bb=BinaryFile.read("d:\\asd.txt");
System.out.println(new String(bb));
}catch(IOException e){
throw new RuntimeException(e);
}


}

}

结果public class Animal{
private String name;
private int age;
public Animal(String name,int age){
this.name=name;
this.age=age;
}
}
我这里输出正常,不知道lZ什么情况

62,620

社区成员

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

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