我有一个用 Visual Basic 5.0 制作的程序创建的二进制文件。该文件只包含一堆Long
来自 Visual Basic 世界的值。我知道Long
在 Visual Basic 5.0 中的大小是 4 个字节,但我不知道字节顺序。
我尝试使用各种“读取”方法使用 DataInputStream 解析文件,但我似乎得到了“错误”(即负)值。
如何阅读并使用 Java 正确解释它?Visual Basic 5.0 中Long的字节顺序是什么?
下面是我正在尝试使用的某种代码;我正在尝试阅读 2Long
秒并在屏幕上打印出来,然后再阅读 2 秒等。
try {
File dbFile = new File(dbFolder + fileINA);
FileInputStream fINA = new FileInputStream(dbFile);
dINA = new DataInputStream(fINA);
long counter = 0;
while (true) {
Integer firstAddress = dINA.readInt();
Integer lastAddress = dINA.readInt();
System.out.println(counter++ + ": " + firstAddress + " " + lastAddress);
}
}
catch(IOException e) {
System.out.println ( "IO Exception =: " + e );
}