Java Object Serialize serialize(Object object)

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

Description

serialize

License

LGPL

Declaration

public static String serialize(Object object) throws IOException 

Method Source Code

//package com.java2s;
/*//w  ww.java 2  s.c o  m
 * Hibernate Search, full-text search for your domain model
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later
 * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
 */

import java.io.ByteArrayOutputStream;
import java.io.IOException;

import java.io.ObjectOutputStream;
import java.util.Base64;

public class Main {
    public static String serialize(Object object) throws IOException {
        try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
                ObjectOutputStream oos = new ObjectOutputStream(baos)) {
            oos.writeObject(object);
            oos.flush();
            byte bytes[] = baos.toByteArray();
            return Base64.getEncoder().encodeToString(bytes);
        }
    }
}

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)