A novel approach: If your array of numbers are unique integers you could write them out as a run-length encoded "bit set". This would give a very compact representation, meaning less I/O. I would suggest this approach for storing very large arrays of unique integers.
For example, suppose your array contains the values [1 ,2 ,3 ,5 ,9]
, your bit set would look like this:
[1, 0, 0, 0, 1, 0, 1, 1, 1]
... and your RLE encoded bit-set would be:
013113
... which is intepreted as "0 zeros, 1 one, 3 zeros, 1 one, etc".
You could choose to either persist the RLE encoded string as characters or using a binary format.