62,614
社区成员
发帖
与我相关
我的任务
分享
package com.tw.test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;
public class Read {
private String filename;
private int size;
public Read(String filename, int size) {
this.filename = filename;
this.size = size;
}
public void read() {
File file1 = new File(filename);
FileInputStream is=null;
try {
is = new FileInputStream(file1);
byte[] var = new byte[size];
byte[] var2=new byte[4];
int data;
while ((data = is.read(var)) != -1) {
var2=Arrays.copyOf(var, 4);
System.out.println(var2);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static void main(String args[]) {
Read test = new Read("C:\\FileB100512010DCBB4.pos", 48);
test.read();
}
}
运行结果如下:
[B@dc8569
[B@1bab50a
[B@c3c749
[B@150bd4d
[B@1bc4459
[B@12b6651
[B@4a5ab2
[B@1888759
[B@6e1408