/** Creates a new byte-buffer input stream by mapping a given file channel. * * @param fileChannel the file channel that will be mapped. * @param mapMode this must be {@link MapMode#READ_ONLY}. * @return a new byte-buffer input stream over the contents of <code>fileChannel</code>. */ public static ByteBufferInputStream map( final FileChannel fileChannel, final MapMode mapMode ) throws IOException { final long size = fileChannel.size(); final int chunks = (int)( ( size + ( CHUNK_SIZE - 1 ) ) / CHUNK_SIZE ); final ByteBuffer[] byteBuffer = new ByteBuffer[ chunks ]; for( int i = 0; i < chunks; i++ ) byteBuffer[ i ] = fileChannel.map( mapMode, i * CHUNK_SIZE, Math.min( CHUNK_SIZE, size - i * CHUNK_SIZE ) ); byteBuffer[ 0 ].position( 0 ); final boolean[] readyToUse = new boolean[ chunks ]; //BooleanArrays.fill( readyToUse, true ); for (int i = 0; i < readyToUse.length; i++) { readyToUse[i] = true; } return new ByteBufferInputStream( byteBuffer, size, 0, readyToUse ); }
/** Creates a new byte-buffer input stream by mapping a given file channel. * * @param fileChannel the file channel that will be mapped. * @param mapMode this must be {@link MapMode#READ_ONLY}. * @return a new byte-buffer input stream over the contents of <code>fileChannel</code>. */ public static ByteBufferInputStream map( final FileChannel fileChannel, final MapMode mapMode ) throws IOException { final long size = fileChannel.size(); final int chunks = (int)( ( size + ( CHUNK_SIZE - 1 ) ) / CHUNK_SIZE ); final ByteBuffer[] byteBuffer = new ByteBuffer[ chunks ]; for( int i = 0; i < chunks; i++ ) byteBuffer[ i ] = fileChannel.map( mapMode, i * CHUNK_SIZE, Math.min( CHUNK_SIZE, size - i * CHUNK_SIZE ) ); byteBuffer[ 0 ].position( 0 ); final boolean[] readyToUse = new boolean[ chunks ]; //BooleanArrays.fill( readyToUse, true ); for (int i = 0; i < readyToUse.length; i++) { readyToUse[i] = true; } return new ByteBufferInputStream( byteBuffer, size, 0, readyToUse ); }
public ByteBufferInputStream copy() { return new ByteBufferInputStream( byteBuffer.clone(), size, curr, new boolean[ n ] ); } }
/** Creates a new byte-buffer input stream by mapping a given file channel. * * @param fileChannel the file channel that will be mapped. * @param mapMode this must be {@link MapMode#READ_ONLY}. * @return a new byte-buffer input stream over the contents of <code>fileChannel</code>. */ public static ByteBufferInputStream map( final FileChannel fileChannel, final MapMode mapMode ) throws IOException { final long size = fileChannel.size(); final int chunks = (int)( ( size + ( CHUNK_SIZE - 1 ) ) / CHUNK_SIZE ); final ByteBuffer[] byteBuffer = new ByteBuffer[ chunks ]; for( int i = 0; i < chunks; i++ ) byteBuffer[ i ] = fileChannel.map( mapMode, i * CHUNK_SIZE, Math.min( CHUNK_SIZE, size - i * CHUNK_SIZE ) ); byteBuffer[ 0 ].position( 0 ); final boolean[] readyToUse = new boolean[ chunks ]; //BooleanArrays.fill( readyToUse, true ); for (int i = 0; i < readyToUse.length; i++) { readyToUse[i] = true; } return new ByteBufferInputStream( byteBuffer, size, 0, readyToUse ); }
public ByteBufferInputStream copy() { return new ByteBufferInputStream( byteBuffer.clone(), size, curr, new boolean[ n ] ); } }
public ByteBufferInputStream copy() { return new ByteBufferInputStream( byteBuffer.clone(), size, curr, new boolean[ n ] ); } }