I hava a binary file (actually a dBF) I would like to read with Java. I am using a FileInputStream and a BufferedReader then reading the required bytes it a char[].
FileInputStream fis;
char[] header = new char[32];
try {
fis = new FileInputStream(source_url);
BufferedReader br;
String line;
br = new BufferedReader(new InputStreamReader(fis, Charset.forName("UTF-8")));
br.read(header);
....
The problem is that the values I read into the array aren't always exactly what is in the file. For example the value 0xE1 is read as 0xFD. I have tried different character sets with no change and reading the value as various types long, int, byte, and using format string to hex, in all cases it looks like 0xFD.
The values are definatley wrong, I can read okay in a C++ program, because it understands unsigned ints, and can read in hex fileviewer.
Am I using the correct classes to read binary data? Am I missing something? I'm trying to avoid using external libraries as I'm just trying to read the file which should be pretty simple.
XxxxReaderare for reading text. Classes calledXxxxxInputStreamare for reading binary data.