public static void writeFully(FileChannel file,long pos,ByteBuffer src){
  try {
    int off=0;
    do {
      int len=file.write(src,pos + off);
      off+=len;
    }
 while (src.remaining() > 0);
  }
 catch (  IOException e) {
    throw newIllegalStateException(ERROR_WRITING_FAILED,"Writing to {0} failed; length {1} at {2}",file,src.remaining(),pos,e);
  }
}

public static void writeFully ( FileChannel file , long pos , ByteBuffer src ) { try { int off = 0 ; do { int len = file . write ( src , pos + off ) ; off += len ; } while ( src . remaining ( ) > 0 ) ; } catch ( IOException e ) { throw newIllegalStateException ( ERROR_WRITING_FAILED , "Writing to {0} failed; length {1} at {2}" , file , src . remaining ( ) , pos , e ) ; } }
write to a file channel .
