Memory-mapped files in Java
I've been trying to write some very fast Java code that has to do a lot of I/O. I'm using a memory mapped file that returns a ByteBuffer: public static ByteBuffer byteBufferForFile(String fname){ FileChannel vectorChannel; ByteBuffer vector; try { vectorChannel = new FileInputStream(fname).getChannel(); } catch (FileNotFoundException e1) { e1.printStackTrace(); return null; } try { vector = vectorChannel.map(MapMode.READ_ONLY,0,vectorChannel.size()); } catch (IOException e) { e.printStackTrace(); return null; } return vector; } The problem that I'm having is that the ByteBuffer .array() method