public long writeValue(OutputStream out) throws IOException {
  DataInputStream dis=getValueStream();
  long size=0;
  try {
    int chunkSize;
    while ((chunkSize=valueBufferInputStream.getRemain()) > 0) {
      chunkSize=Math.min(chunkSize,MAX_VAL_TRANSFER_BUF_SIZE);
      valTransferBuffer.setSize(chunkSize);
      dis.readFully(valTransferBuffer.getBytes(),0,chunkSize);
      out.write(valTransferBuffer.getBytes(),0,chunkSize);
      size+=chunkSize;
    }
    return size;
  }
  finally {
    dis.close();
  }
}

public long writeValue ( OutputStream out ) throws IOException { DataInputStream dis = getValueStream ( ) ; long size = 0 ; try { int chunkSize ; while ( ( chunkSize = valueBufferInputStream . getRemain ( ) ) > 0 ) { chunkSize = Math . min ( chunkSize , MAX_VAL_TRANSFER_BUF_SIZE ) ; valTransferBuffer . setSize ( chunkSize ) ; dis . readFully ( valTransferBuffer . getBytes ( ) , 0 , chunkSize ) ; out . write ( valTransferBuffer . getBytes ( ) , 0 , chunkSize ) ; size += chunkSize ; } return size ; } finally { dis . close ( ) ; } }
writing the value to the output stream . this method avoids copying value data from scanner into user buffer , then writing to the output stream . it does not require the value length to be known .
