synchronized public long transferTo(final RandomAccessFile out) throws IOException {
  final long count=nextOffset.get();
  final FileChannel outChannel=out.getChannel();
  final long toPosition=outChannel.position();
  buffer.limit((int)count);
  buffer.position(0);
  FileChannelUtility.writeAll(outChannel,buffer,toPosition);
  outChannel.position(toPosition + count);
  return count;
}

synchronized public long transferTo ( final RandomAccessFile out ) throws IOException { final long count = nextOffset . get ( ) ; final FileChannel outChannel = out . getChannel ( ) ; final long toPosition = outChannel . position ( ) ; buffer . limit ( ( int ) count ) ; buffer . position ( 0 ) ; FileChannelUtility . writeAll ( outChannel , buffer , toPosition ) ; outChannel . position ( toPosition + count ) ; return count ; }
note : this is synchronized so that concurrent writers must block during this operation .
