Serializes an {@code Serializable} to the specified stream.

The given stream will not be close.

@param object the object to serialize to bytes
@param output the stream to write to, must not be null
@throws IOException in case the load operation failed
192361
private static void serialize(Serializable object, OutputStream output) throws IOException {
        BufferedOutputStream bos = new BufferedOutputStream(output);
        ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(object);
        bos.flush();
    }
650180
public static void writeJson(@javax.annotation.Nonnull final OutputStream out, final Object obj) throws IOException {
    final ObjectMapper mapper = new ObjectMapper().enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL)
      .enable(SerializationFeature.INDENT_OUTPUT);
    @javax.annotation.Nonnull final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    mapper.writeValue(buffer, obj);
    out.write(buffer.toByteArray());
  }
308524
static void serialize(DataOutput out, Serializers serializers)
      throws IOException {
    StringBuilder msg = new StringBuilder(String.format("Serialize %d serializer classes:", serializers.serializers.values().size()));
    int size = serializers.serializers.values().size();

    out.writeInt(size);
    if (size > 0) {
      for (SerializerWrapper sw : serializers.serializers.values()) {
        int index = sw.index;
        String name = sw.serializer.getClass().getName();

        out.writeInt(index);
        out.writeUTF(name);

        msg.append(String.format("%n  (%d) %s", index, name));
      }
      LOGGER.info(msg.toString());
    }
  }
1094379
public void writeObject (Output output, Object object) {
		if (output == null) throw new IllegalArgumentException("output cannot be null.");
		if (object == null) throw new IllegalArgumentException("object cannot be null.");
		beginObject();
		try {
			if (references && writeReferenceOrNull(output, object, false)) return;
			if (TRACE || (DEBUG && depth == 1)) log("Write", object, output.position());
			getRegistration(object.getClass()).getSerializer().write(this, output, object);
		} finally {
			if (--depth == 0 && autoReset) reset();
		}
	}
161428
private void writeObject(ObjectOutputStream stream) throws IOException {

        stream.defaultWriteObject();

        // not all values in the property bag are going to be serializable; we
        // need to be careful which parts of the bag we serialize
        //
        Map<Object, Object> tempProperties = new HashMap<Object, Object>();
        for (Object key : this.properties.keySet()) {
            Object value = this.properties.get(key);

            if (value instanceof Serializable || value instanceof Externalizable) {

                tempProperties.put(key, value);
            } else {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "value for key \"" + key + "\" is not serializable");
                }
            }
        }

        stream.writeObject(tempProperties);
    }
834116
private void writeObject(ObjectOutputStream out) throws IOException {
        Storable s = mStorable;
        if (s == null) {
            out.write(0);
        } else {
            out.write(1);
            out.writeObject(s.storableType());
            try {
                s.writeTo(out);
            } catch (SupportException e) {
                throw new IOException(e);
            }
        }
    }
593978
private void writeObject(ObjectOutputStream out) throws IOException {
        out.writeObject(clazz);
        out.writeInt(defaultBatchSize);
        out.writeInt(queryIndex);
        out.writeObject(cursor);
        out.writeObject(generators);
        out.writeInt(generatorIndex);
        writeObjects(out);
    }
247341
public void writeObject(@NonNull ObjectOutputStream stream) throws IOException {
        stream.writeObject(id);
        stream.writeLong(createdTime);
        stream.writeLong(lastAccessedTime);
        stream.writeInt(maxInactiveInterval);
        stream.writeBoolean(isNew);
        stream.writeBoolean(isValid);
        stream.writeInt(mAttributes.size());
        String keys[] = mAttributes.keySet().toArray(EMPTY_ARRAY);
        for (String key : keys) {
            Object value = mAttributes.get(key);
            if (value != null && value instanceof Serializable) {
                stream.writeObject(key);
                stream.writeObject(value);
            }
        }
    }
935876
private void writeObject(ObjectOutputStream out) throws IOException {
		// serialize the parent fields and the final fields
		out.defaultWriteObject();

		// write the input split
		((Writable) mapreduceInputSplit).write(out);
	}
778439
public void serialize(final OutputStream out) throws IOException {
    final Writer writer = new BufferedWriter(new OutputStreamWriter(out));
    for (final Map.Entry<String, String> entry : this.multiMap.entries()) {
      writer.write(
          entry.getKey() + IOUtils.TAB_DELIMITER + entry.getValue() + "\n");
    }
    writer.flush();
  }
1030034
public void writeObject (ObjectOutputStream out)
        throws IOException
    {
        out.writeInt(size());
        for (E value : this) {
            out.writeObject(value);
        }
    }
1223549
public void serializeStatusObject(IoBuffer out, StatusObject statusObject) {
        Map<?, ?> statusMap = new BeanMap(statusObject);
        Output output = new Output(out);
        Serializer.serialize(output, statusMap);
    }
1360962
private void writeObject(final ObjectOutputStream out) throws IOException {
		// write all the non-transient fields
		out.defaultWriteObject();

		// write the non-serializable default value field
		if (defaultValue == null) {
			// we don't have a default value
			out.writeBoolean(false);
		} else {
			// we have a default value
			out.writeBoolean(true);

			byte[] serializedDefaultValue;
			try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
					DataOutputViewStreamWrapper outView = new DataOutputViewStreamWrapper(baos)) {

				TypeSerializer<T> duplicateSerializer = serializer.duplicate();
				duplicateSerializer.serialize(defaultValue, outView);

				outView.flush();
				serializedDefaultValue = baos.toByteArray();
			}
			catch (Exception e) {
				throw new IOException("Unable to serialize default value of type " +
						defaultValue.getClass().getSimpleName() + ".", e);
			}

			out.writeInt(serializedDefaultValue.length);
			out.write(serializedDefaultValue);
		}
	}
518982
private void writeObject(java.io.ObjectOutputStream out) throws IOException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "writeObject", out);

        try {
            if (requiresInit)
                lazyInitForReading();

            // If message is in write mode, get data into byte array so that we
            // can restore the output stream during readObject.
            // If message is in read mode, store the offset so that we can skip
            // the input stream during readObject.
            if (isBodyReadOnly()) {
                // read mode
                streamOffset = dataBuffer.length - readStream.available();
            }
            else {
                // write mode
                if (_writeBytes != null) {
                    // SIB0121: If the producer has promised not to modify the payload after set,
                    // _writeBytes will always be null
                    dataBuffer = _writeBytes.toByteArray();
                }
            }
            // Use the default mechanism to write the fields.
            out.defaultWriteObject();
        } catch (IOException e) {
            // No FFDC code needed
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.debug(this, tc, "Error during writeObject", e);
            // pass on
            throw e;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "writeObject");
    }
377085
public static void serialize(File file, SerializableObject object) throws IOException {
		AtomicFile atomicFile = new AtomicFile(file);
		FileOutputStream stream = null;
		try {
			stream = atomicFile.startWrite();
			DataOutputStream out = new DataOutputStream(stream);
			object.writeExternal(out);
			atomicFile.finishWrite(stream); // serialization was successful
		} catch (Exception e) {
			atomicFile.failWrite(stream); // serialization failed
			throw new IOException(e); // throw exception up the chain
		}
	}
142136
public final void serialize(OutputStream out) throws IOException {
        out.write(Jackson.toJsonString(this).getBytes(UTF8));
        out.flush();
    }
297943
public static void writeGzipObjectToStream(final Object o, OutputStream out) {
    out = new BufferedOutputStream(out);
    try {
      out = new GZIPOutputStream(out, true);
      final ObjectOutputStream oos = new ObjectOutputStream(out);
      oos.writeObject(o);
      oos.flush();
    } catch (final IOException e) {
      e.printStackTrace();
    }
  }