public void write(String record) throws IOException {
  Chunk ch=currentChunk();
  boolean hasNewLine=record.endsWith("\n");
  int rawBytesToWrite=record.length();
  if (!hasNewLine) {
    rawBytesToWrite+=1;
  }
  if ((ch.rawBytes + rawBytesToWrite) > chunkThreshold) {
    finishChunk();
    initChunkWriter();
    Chunk newCh=new Chunk();
    newCh.firstOffset=ch.firstOffset + ch.numRecords;
    newCh.byteOffset=ch.byteOffset + ch.compressedByteLength;
    chunks.add(newCh);
    ch=newCh;
  }
  writer.append(record);
  if (!hasNewLine) {
    writer.newLine();
  }
  ch.rawBytes+=rawBytesToWrite;
  ch.numRecords++;
}

public void write ( String record ) throws IOException { Chunk ch = currentChunk ( ) ; boolean hasNewLine = record . endsWith ( "\n" ) ; int rawBytesToWrite = record . length ( ) ; if ( ! hasNewLine ) { rawBytesToWrite += 1 ; } if ( ( ch . rawBytes + rawBytesToWrite ) > chunkThreshold ) { finishChunk ( ) ; initChunkWriter ( ) ; Chunk newCh = new Chunk ( ) ; newCh . firstOffset = ch . firstOffset + ch . numRecords ; newCh . byteOffset = ch . byteOffset + ch . compressedByteLength ; chunks . add ( newCh ) ; ch = newCh ; } writer . append ( record ) ; if ( ! hasNewLine ) { writer . newLine ( ) ; } ch . rawBytes += rawBytesToWrite ; ch . numRecords ++ ; }
writes string to file , assuming this is a single record if there is no newline at then end we will add one
