private int readLocal(final ByteBuffer buffer,final long position) throws IOException {
  final int requestLen=buffer.remaining();
  final long eof=m_channel.size();
  if (eof < (position + requestLen)) {
    if (position == eof)     return -1;
    final int len=(int)(eof - position);
    buffer.limit(len);
    FileChannelUtility.readAll(m_reopener,buffer,position);
    buffer.limit(requestLen);
  }
 else {
    FileChannelUtility.readAll(m_reopener,buffer,position);
  }
  return requestLen - buffer.remaining();
}

private int readLocal ( final ByteBuffer buffer , final long position ) throws IOException { final int requestLen = buffer . remaining ( ) ; final long eof = m_channel . size ( ) ; if ( eof < ( position + requestLen ) ) { if ( position == eof ) return - 1 ; final int len = ( int ) ( eof - position ) ; buffer . limit ( len ) ; FileChannelUtility . readAll ( m_reopener , buffer , position ) ; buffer . limit ( requestLen ) ; } else { FileChannelUtility . readAll ( m_reopener , buffer , position ) ; } return requestLen - buffer . remaining ( ) ; }
simulates the normal inputstream request , returning - 1 if eof and only asking for as much as can be read - do not try to read past eof . in fact , we probably do not need to make these checks since the object streaming used only ever asks for what is expected .
