Java ByteBuffer from getByteBuffer(String filePath, int start, long size)

Here you can find the source of getByteBuffer(String filePath, int start, long size)

Description

get Byte Buffer

License

Apache License

Declaration

public static ByteBuffer getByteBuffer(String filePath, int start, long size) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class Main {
    public static ByteBuffer getByteBuffer(String filePath, int start, long size) throws IOException {
        File binaryFile = new File(filePath);
        FileChannel binaryFileChannel = new RandomAccessFile(binaryFile, "r").getChannel();

        return binaryFileChannel.map(FileChannel.MapMode.READ_ONLY, start, size);
    }/*w w  w.j a  v a  2  s  .com*/
}

Related

  1. getByteBuffer(ByteBuffer source, int count)
  2. getByteBuffer(final String string, final Charset charset)
  3. getByteBuffer(int size)
  4. getByteBuffer(Object obj)
  5. getByteBuffer(String base64)
  6. getByteBufferArray(ByteBuffer byteBuffer)
  7. getByteBufferAsString(ByteBuffer buff)
  8. getByteBufferByString(String message)
  9. getByteBufferFromBytes(byte[] data)