cdm/src/main/java/ucar/nc2/NetcdfFile.java
protected long readToByteChannel(ucar.nc2.Variable v, Section section, WritableByteChannel wbc)
          throws java.io.IOException, ucar.ma2.InvalidRangeException {

    //if (unlocked)
    //  throw new IllegalStateException("File is unlocked - cannot use");

    if ((spi == null) || v.hasCachedData())
      return IospHelper.copyToByteChannel(v.read(section), wbc);

    return spi.readToByteChannel(v, section, wbc);
  }
protected long readToByteChannel(ucar.nc2.Variable v, Section section, WritableByteChannel wbc)
          throws java.io.IOException, ucar.ma2.InvalidRangeException {

    //if (unlocked)
    //  throw new IllegalStateException("File is unlocked - cannot use");

    if ((spi == null) || v.hasCachedData())
      return IospHelper.copyToByteChannel(v.read(section), wbc);

    return spi.readToByteChannel(v, section, wbc);
  }
Read data from a top level Variable and send data to a WritableByteChannel. Experimental.

@param v       a top-level Variable
@param section the section of data to read.
There must be a Range for each Dimension in the variable, in order.
Note: no nulls allowed. IOSP may not modify.
@param wbc     write data to this WritableByteChannel
@return the number of bytes written to the channel
@throws java.io.IOException            if read error
@throws ucar.ma2.InvalidRangeException if invalid section