I need help with an issue that i have. I want to read a binary file.
The content of the file are: 0000000010001100
I'm using the following code to reach my goal:
InputStream is = new FileInputStream(new File("/test.bin"));
DataInputStream din = new DataInputStream(is);
System.out.println(din.readByte() & 0xFF);
I was expecting that the output was 0, because an unsigned byte of eight zeros is 0. But the code prints 48.
Can some开发者_运维技巧one tell me what i am doing wrong and explain me how can i have an output of 48 ?
Are you sure you didn't inadvertenly save a '0' as the first character in the file? The ASCII for the text character '0' is 48.
精彩评论