Проблема с чтение бинарного файла
Пытаюсь считать бинарный файл, получаю байтовый массив.
try {
File file = new File(path + fileName);
FileInputStream is = new FileInputStream(file);
int i;
while ((i = is.read()) != -1) {
System.out.print(i);
}
is.close();
} catch (Exception e) {
e.printStackTrace();
}
Что я могу сделать с этим массивом байтов и как мне перевести это в строки или символы, при кодировки файла стоит ANSI кодировка, что является по сути адаптивной кодировкой и не подходит не под одну, если я поставлю char
, то будут вылезать сплошные кракозябры.
Сам файл состоит из вот таких вот тегов:
0x42525344
Header section – must be the first section within the file.
0x44495247
Grid section – describes a 2D matrix of Z values.
0x41544144
Data section – contains a variable amount of data. The size of the data section is given by the Size field in the tag structure.
0x49544c46
Fault Info section – describes the fault traces used when creating the grid.
И чисел long
32 bit signed integer
double
64 bit double precision floating point value
Если кротко, то это surfer 7 grd binary
файл (https://surferhelp.goldensoftware.com/topics/surfer_7_grid_file_format.htm) - Ссылка на документацию к формату.