Java FileChannel Read readFully(FileChannel channel, long offset, ByteBuffer buf)

Here you can find the source of readFully(FileChannel channel, long offset, ByteBuffer buf)

Description

read Fully

License

Open Source License

Declaration

static void readFully(FileChannel channel, long offset, ByteBuffer buf) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.*;
import java.nio.*;
import java.nio.channels.FileChannel;

public class Main {
    static void readFully(FileChannel channel, long offset, ByteBuffer buf) throws IOException {
        int remaining = buf.limit() - buf.position();

        while (remaining > 0) {
            int read = channel.read(buf, offset);
            if (read < 0)
                throw new EOFException();
            remaining -= read;/*from   w  w  w  . j  a  va  2 s. c  o m*/
        }
    }
}

Related

  1. readFully(FileChannel channel, ByteBuffer buffer)
  2. readFully(FileChannel channel, ByteBuffer buffer, long ptr)
  3. readFully(FileChannel channel, ByteBuffer dst)
  4. readFully(FileChannel fileChannel, long filePosition, ByteBuffer buffer)