Given a byte array I can make a file from it with the code
Files.write(String path, byte[] byteArray)
The problem is, since I have to work with extremely large array sizes, and I can’t make an array with a long size
long n = 100000000;
byte byteArray = new byte[n]; //ERROR! Required int, found long
what I do is I have several byte arrays. For example, since I can’t have a 4gb array, I make 20 byte arrays of 200mb. These 20 arrays represent the information of a file. Now, how can I create a file from this byte arrays? The only way I know is using Files.write, but that only works with 1 array.
Thanks in advance.
You could use:
On the calls after the first one.
A better method (that doesn’t require re-opening the file 20 times) would be using a FileOutputStream like: