/** * Creates a {@link IRandomAccessSource} based on memory mapping a file channel. * Unless you are explicitly working with a {@code FileChannel} already, it is better to use * {@link RandomAccessSourceFactory#createBestSource(String)}. * If the file is large, it will be opened using a paging strategy. * @param channel the name of the file or resource to create the {@link IRandomAccessSource} for * @return the newly created {@link IRandomAccessSource} */ public IRandomAccessSource createBestSource(FileChannel channel) throws java.io.IOException { if (channel.size() <= PagedChannelRandomAccessSource.DEFAULT_TOTAL_BUFSIZE){ // if less than the fully mapped usage of PagedFileChannelRandomAccessSource, just map the whole thing and be done with it return new GetBufferedRandomAccessSource(new FileChannelRandomAccessSource(channel)); } else { return new GetBufferedRandomAccessSource(new PagedChannelRandomAccessSource(channel)); } }
/** * Creates a {@link IRandomAccessSource} based on memory mapping a file channel. * Unless you are explicitly working with a {@code FileChannel} already, it is better to use * {@link RandomAccessSourceFactory#createBestSource(String)}. * If the file is large, it will be opened using a paging strategy. * @param channel the name of the file or resource to create the {@link IRandomAccessSource} for * @return the newly created {@link IRandomAccessSource} */ public IRandomAccessSource createBestSource(FileChannel channel) throws java.io.IOException { if (channel.size() <= PagedChannelRandomAccessSource.DEFAULT_TOTAL_BUFSIZE){ // if less than the fully mapped usage of PagedFileChannelRandomAccessSource, just map the whole thing and be done with it return new GetBufferedRandomAccessSource(new FileChannelRandomAccessSource(channel)); } else { return new GetBufferedRandomAccessSource(new PagedChannelRandomAccessSource(channel)); } }