code: public void write(Bean bean, boolean rootType, OutputStream output) throws IOException {
          if (bean == null) {
              throw new NullPointerException("bean");
          }
          if (output == null) {
              throw new NullPointerException("output");
          }
          if (referencing) {
              if (!(bean instanceof ImmutableBean)) {
                  throw new IllegalArgumentException(
                      "Referencing binary format can only write ImmutableBean instances: " + bean.getClass().getName());
              }
              new JodaBeanReferencingBinWriter(settings, output).write((ImmutableBean) bean);
          } else {
              new JodaBeanStandardBinWriter(settings, output).write(bean, rootType);
          }
      }
docs: Writes the bean to the {@code OutputStream}.
  
  @param bean  the bean to output, not null
  @param rootType  true to output the root type
  @param output  the output stream, not null
  @throws IOException if an error occurs