Skip to main content

Wierd problem reading file

7 replies [Last post]
olelindbjerg
Offline
Joined: 2010-02-17

Hi
se following codesnippet below this.
I'm reading a binary file from a logger, where each record are timestamped as seconds after a initial time, and in reverse byteorder. Each record are read by fillowing method, and afte the codesnippet are some output written from left as:
Time_n hex binary
Suddently there's a wierd reading and they continues to come in random order.

PLEASE HELP.
Ole Lindbjerg

private boolean readOneEntry(BufferedReader in)
throws IOException
{
int data[] = new int[12];
for (int i = 0; i < 12; i++)
{
data[i] = in.read();
}
// treat as short but changing byteorder
Time_n = (data[2]) * 256 + (data[3]);
dim1_n = (data[6]) * 256 + (data[7]);
dim2_n = (data[10]) * 256 + (data[11]);

.. and the output:

0 0 00000000000000000000000000000000
238 ee 00000000000000000000000011101110
257 101 00000000000000000000000100000001
276 114 00000000000000000000000100010100
296 128 00000000000000000000000100101000
315 13b 00000000000000000000000100111011
334 14e 00000000000000000000000101001110
354 162 00000000000000000000000101100010
373 175 00000000000000000000000101110101
8496 2130 00000000000000000010000100110000 should be 393
595 253 00000000000000000000001001010011 should be 412
431 1af 00000000000000000000000110101111

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
srinuchennupati
Offline
Joined: 2010-03-25

we can read the file with out any problem .it is possible

phill_8
Offline
Joined: 2010-04-13

Yes it's readable , the code is working fine

olelindbjerg
Offline
Joined: 2010-02-17

I'll try to paste the code again:
private boolean readOneEntry(BufferedReader in)
throws IOException
{
int data[] = new int[12];
for (int i = 0; i < 12; i++)
{
data[i] = in.read();
}
// treat as short but changing byteorder
Time_n = (data[2]) * 256 + (data[3]);
dim1_n = (data[6]) * 256 + (data[7]);
dim2_n = (data[10]) * 256 + (data[11]);
//set bufferlengths
Buffer_WindData = new short[(int) dim1_n * (int) dim2_n];
WindData_Byte_Buffer = new char[2 * (int) dim1_n * (int) dim2_n];
WindData_Array = new double[(int) (dim1_n + 2) * (int) dim2_n];

and the result which really are the Time_n in diff. formats:

0 0 00000000000000000000000000000000
238 ee 00000000000000000000000011101110
257 101 00000000000000000000000100000001
276 114 00000000000000000000000100010100
296 128 00000000000000000000000100101000
315 13b 00000000000000000000000100111011
334 14e 00000000000000000000000101001110
354 162 00000000000000000000000101100010
373 175 00000000000000000000000101110101
8496 2130 00000000000000000010000100110000 shoud be 393
595 253 00000000000000000000001001010011
431 1af 00000000000000000000000110101111
451 1c3 00000000000000000000000111000011

olelindbjerg
Offline
Joined: 2010-02-17

ok , somehow it get truncated so I stop the thread and try something else.

tera_byte
Offline
Joined: 2010-02-13

dude use patebin.com
or use [code] before your code and [/code] after your code

olelindbjerg
Offline
Joined: 2010-02-17

It seemes as some of the text got cut off, so anyone in for helping please request the whole message.
Ole

tera_byte
Offline
Joined: 2010-02-13

why don't you paste your whole code or use pastebin.com and then maybe me or someone can help you .