Situation:
I have an int[60 million] and a long [240 million] and i want to save them to a file.
Problem:
I need a bulk write like FileOutputStream.write(byte[] b, int off, int len).
All bulk writes seem to require byte [] or ByteBuffer.
There seems to be no way to convert an int[] to a byte[] or ByteBuffer.
Failed attempts:
I tried allocating my arrays with ByteBuffer.allocate() and then using ByteBuffer.asLongBuffer.array(), but that function is not supported.
I tried staying with a LongBuffer instead, however, LongBuffer.put() is also optional and not supported.
I tried to use ByteBuffer.wrap(new byte[]).asLongBuffer.array(), but the function is still not supported.
Converting my longs to byte[] via bitshifting will take ages, and it is a time-critical application.
Possible solutions:
Find a bulk write that accepts int[] and long[].
Find an intermediate type that can be backed by int[] and long[] which is supported by a bulk write.
Note:
I come from C and am very frustrated to not be able to just say FileOutputStream.write((byte [])int[]).
Yes, I used google and could not find anything useful.
Any help would be greatly appreciated.
Edit:
Im on Win7x64
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02, mixed mode)