code: protected void drain() throws IOException {
          if (primitiveTypes == null || primitiveTypesBuffer == null) {
              return;
          }
  
          // If we got here we have a Stream previously created
          int offset = 0;
          byte[] written = primitiveTypesBuffer.toByteArray();
          // Normalize the primitive data
          while (offset < written.length) {
              int toWrite = written.length - offset > 1024 ? 1024
                      : written.length - offset;
              if (toWrite < 256) {
                  output.writeByte(TC_BLOCKDATA);
                  output.writeByte((byte) toWrite);
              } else {
                  output.writeByte(TC_BLOCKDATALONG);
                  output.writeInt(toWrite);
              }
  
              // write primitive types we had and the marker of end-of-buffer
              output.write(written, offset, toWrite);
              offset += toWrite;
          }
  
          // and now we're clean to a state where we can write an object
          primitiveTypes = null;
          primitiveTypesBuffer = null;
      }
docs: Writes buffered data to the target stream. This is similar to {@code
  flush} but the flush is not propagated to the target stream.
  
  @throws IOException
  if an error occurs while writing to the target stream.