P
PaowZ
Hi there!
I'm trying using this method but I'm experimenting some issues. I
explain:
1.
byte buffer[] = new byte[3]; //my 3-bytes-long buffer
2.
res = in.read(buffer); // I read 3 bytes from file to
put in the array
3.
String bloc1 = Integer.toBinaryString(buffer[0]); // I want
the first byte to be represented in string format
4.
String bloc2 = Integer.toBinaryString(buffer[1]); // the
second byte
5.
String bloc3 = Integer.toBinaryString(buffer[2]); // the
third byte
This is what I get, when it works:
1.
01010010 | 01100001 | 01110010
Here, no problem.. I get 3 bytes, I mean 24 bits in string format.
After some iterations (always the same) I get weird thing, such as:
1.
00000000 | 11111111111111111111111111001111 |
11111111111111111111111110010000
As you can see, two string formatted bytes are not bytes. Indeed,
they're 32 bits long.
Do you have any idea of this trouble using toBinaryString ?
Thanks a lot
V.
I'm trying using this method but I'm experimenting some issues. I
explain:
1.
byte buffer[] = new byte[3]; //my 3-bytes-long buffer
2.
res = in.read(buffer); // I read 3 bytes from file to
put in the array
3.
String bloc1 = Integer.toBinaryString(buffer[0]); // I want
the first byte to be represented in string format
4.
String bloc2 = Integer.toBinaryString(buffer[1]); // the
second byte
5.
String bloc3 = Integer.toBinaryString(buffer[2]); // the
third byte
This is what I get, when it works:
1.
01010010 | 01100001 | 01110010
Here, no problem.. I get 3 bytes, I mean 24 bits in string format.
After some iterations (always the same) I get weird thing, such as:
1.
00000000 | 11111111111111111111111111001111 |
11111111111111111111111110010000
As you can see, two string formatted bytes are not bytes. Indeed,
they're 32 bits long.
Do you have any idea of this trouble using toBinaryString ?
Thanks a lot
V.