Java Object Serialize serialize(Object object)

Here you can find the source of serialize(Object object)

Description

serialize

License

Open Source License

Declaration

private static byte[] serialize(Object object) throws Exception 

Method Source Code

//package com.java2s;
/*/*from w ww.  j a  v  a  2s .c  o m*/
 * Copyright 2015-2017 the original author or authors.
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v2.0 which
 * accompanies this distribution and is available at
 *
 * http://www.eclipse.org/legal/epl-v20.html
 */

import java.io.ByteArrayOutputStream;

import java.io.ObjectOutputStream;

public class Main {
    private static byte[] serialize(Object object) throws Exception {
        try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream)) {
            objectOutputStream.writeObject(object);
            objectOutputStream.flush();
            return byteArrayOutputStream.toByteArray();
        }
    }
}

Related

  1. serialize(Object object)
  2. serialize(Object object)
  3. Serialize(Object object)
  4. serialize(Object object)
  5. serialize(Object object)
  6. serialize(Object object)
  7. serialize(Object object)
  8. serialize(Object object)
  9. serialize(Object object)