cdm/src/main/java/ucar/unidata/io/RandomAccessFile.java
public long readToByteChannel(WritableByteChannel dest, long offset, long nbytes) throws IOException {

    if (fileChannel == null)
      fileChannel = file.getChannel();

    long need = nbytes;
    while (need > 0) {
      long count = fileChannel.transferTo(offset, need, dest);
      //if (count == 0) break;  // LOOK not sure what the EOF condition is
      need -= count;
      offset += count;
    }
    return nbytes - need;
  }
public long readToByteChannel(WritableByteChannel dest, long offset, long nbytes) throws IOException {

    if (fileChannel == null)
      fileChannel = file.getChannel();

    long need = nbytes;
    while (need > 0) {
      long count = fileChannel.transferTo(offset, need, dest);
      //if (count == 0) break;  // LOOK not sure what the EOF condition is
      need -= count;
      offset += count;
    }
    return nbytes - need;
  }
public long readToByteChannel ( WritableByteChannel dest , long offset , long nbytes ) throws IOException { if ( fileChannel == null ) fileChannel = file . getChannel ( ) ; long need = nbytes ; while ( need > 0 ) { long count = fileChannel . transferTo ( offset , need , dest ) ; //if (count == 0) break;  // LOOK not sure what the EOF condition is
 need -= count ; offset += count ; } return nbytes - need ; }
Read <code>nbytes</code> bytes, at the specified file offset, send to a WritableByteChannel.
This will block until all bytes are read.
This uses the underlying file channel directly, bypassing all user buffers.

@param dest   write to this WritableByteChannel.
@param offset the offset in the file where copying will start.
@param nbytes the number of bytes to read.
@return the actual number of bytes read and transfered
@throws IOException if an I/O error occurs.
Read <code > nbytes< / code > bytes at the specified file offset send to a WritableByteChannel . This will block until all bytes are read . This uses the underlying file channel directly bypassing all user buffers .