I\'ve got a 40MB file in the disk and I need to \"map\" it into memory using a byte array.
At first, I thought writing the file to a ByteArrayOutputStream would be the b
If you really want to map the file into memory, then a FileChannel is the appropriate mechanism.
If all you want to do is read the file into a simple byte[]
(and don't need changes to that array to be reflected back to the file), then simply reading into an appropriately-sized byte[]
from a normal FileInputStream should suffice.
Guava has Files.toByteArray() which does all that for you.