Code example for RandomAccessFile

Methods: getChannel

0
     * enough that we'll just keep the byte[] in memory. 
     */ 
    private static ByteBuffer mapData() {
        RandomAccessFile file = null;
        try { 
            file = new RandomAccessFile(ZONE_FILE_NAME, "r");
            FileChannel channel = file.getChannel();
            ByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
            buffer.order(ByteOrder.BIG_ENDIAN);
            return buffer;
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        } finally { 
            IoUtils.closeQuietly(file);
        } 
    } 
 
    private static TimeZone makeTimeZone(String id) throws IOException {
        // Work out where in the big data file this time zone is. 
        int index = Arrays.binarySearch(ids, id);