62,620
社区成员
发帖
与我相关
我的任务
分享
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);
}
}
}