There is one file that was created with Objective C. In this file there is an array: int[x][y]. There is no problem to read this file ‘as is’ in C and pass only link of the new int[][] as buffer.
But I want to read this file in Java, I’ve tried read it to int[x*y] but values are different because C stores a double array ([][]) not like simple [].
I think the are 2 ways: recreate file for usage in Java or use C++ in java, but maybe there are some easier ways?
UPDATED
Creation of the file (inf Objective C) (the size of array is fixed each time)
NSData *mydata = [NSData dataWithBytes:&areas length:sizeof(areas)];
[mydata writeToFile:filePathData options:NSDataWritingAtomic error:&error];
I imagine the problem is you are reading little endian C data as big endian. If you use DataInputStream it assumes big endian which is only the default for C on big endian machines such as Sparc 😉 and a number of machines now all but dead.
I assume you know the format of the file and if it doesn’t contain the dimensions (width and height), you know what they are.
I suggest you try using
ByteBufferwithorder(ByteOrder.LITTE_ENDIAN)to read the data. There are a number of ways to do this. If you file is smaller than 2 GB I would use a memory mapped file.