E
El Durango
I have to write Java to read a binary file and I am not getting the values I
am looking for.
The format of the file is:
String 4bytes
String 20bytes
String 32bytes
double 8bytes
double 8bytes
double 8bytes
double 8bytes
double 8bytes
Here is a snippet of my code:
fis = new FileInputStream(inputFile);
dis = new DataInputStream(fis);
while(retCode != -1){
retCode = dis.read(caseNameBuf,offset,CASENAMESIZE);
System.out.println(new String(caseNameBuf));
if(retCode == -1){
throw new EOFException();
}
retCode = dis.read(nullBuf,offset,12);
System.out.println(new String(nullBuf));
if(retCode == -1){
throw new EOFException();
}
retCode = dis.read(eventNameBuf,offset,EVENTNAMESIZE);
System.out.println(new String(eventNameBuf));
if(retCode == -1){
throw new EOFException();
}
d = dis.readDouble();
System.out.println(d);
d = dis.readDouble();
System.out.println(d);
d = dis.readDouble();
System.out.println(d);
d = dis.readDouble();
System.out.println(d);
d = dis.readDouble();
System.out.println(d);
}
...
I am getting the correct String data however I cannot get the proper data
for the double values. Can anyone inform me of what mistake I am making
here.
thank you,
Durango.
am looking for.
The format of the file is:
String 4bytes
String 20bytes
String 32bytes
double 8bytes
double 8bytes
double 8bytes
double 8bytes
double 8bytes
Here is a snippet of my code:
fis = new FileInputStream(inputFile);
dis = new DataInputStream(fis);
while(retCode != -1){
retCode = dis.read(caseNameBuf,offset,CASENAMESIZE);
System.out.println(new String(caseNameBuf));
if(retCode == -1){
throw new EOFException();
}
retCode = dis.read(nullBuf,offset,12);
System.out.println(new String(nullBuf));
if(retCode == -1){
throw new EOFException();
}
retCode = dis.read(eventNameBuf,offset,EVENTNAMESIZE);
System.out.println(new String(eventNameBuf));
if(retCode == -1){
throw new EOFException();
}
d = dis.readDouble();
System.out.println(d);
d = dis.readDouble();
System.out.println(d);
d = dis.readDouble();
System.out.println(d);
d = dis.readDouble();
System.out.println(d);
d = dis.readDouble();
System.out.println(d);
}
...
I am getting the correct String data however I cannot get the proper data
for the double values. Can anyone inform me of what mistake I am making
here.
thank you,
Durango.