import java.io.*;
public class foo {
public static void main(String[] args) {
try {
DataInputStream input = new DataInputStream(new FileInputStream(
"data.dat"));
while (input.available() > 0) {
String hex = Integer.toHexString(input.readByte()); //I think this is where the problem is
System.out.print(hex + ' ');
}
} catch (IOException e) {
}
}
}
Output-
ffffff89 50 4e 47 d a 1a a 0 0 0 d 49 48 44 52 0 0 0... (continues)
The output is mostly correct. I can't figure out where these ffffffs are coming in my output. And also single single characters are missing their 0. eg. d should be displayed as 0D