package packet;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Array_input {
public String testDataInputStream(String filepath) throws IOException {
File file = new File(filepath);
DataInputStream din = new DataInputStream(new FileInputStream(file));
StringBuilder hexData = new StringBuilder();
byte temp = 0;
for (int i = 0; i < file.length(); i++) {
temp = din.readByte();
// 以十六进制的无符号整数形式返回一个字符串表示形式。
String str = Integer.toHexString(temp);
if (str.length() == 8) {// 去掉补位的f
str = str.substring(6);
}
if (str.length() == 1) {
str = "0" + str;
}
hexData.append(str);
}
return hexData.toString();
}
}