Java Is Serializable Object isSerializable(Object o)

Here you can find the source of isSerializable(Object o)

Description

is Serializable

License

Open Source License

Declaration

public static boolean isSerializable(Object o) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2015 Composent, Inc. and others. All rights reserved. This
 * program and the accompanying materials are made available under the terms of
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
 * available at http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://w w  w . j a  v  a 2s.  c  o  m
 *   Composent, Inc. - initial API and implementation
 ******************************************************************************/

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

public class Main {
    public static boolean isSerializable(Object o) {
        ObjectOutputStream oos = null;
        try {
            oos = new ObjectOutputStream(new ByteArrayOutputStream());
            oos.writeObject(o);
            return true;
        } catch (IOException e) {
            return false;
        } finally {
            try {
                if (oos != null)
                    oos.close();
            } catch (IOException e) {
                // do nothing
            }
        }
    }
}

Related

  1. isSerializable(Class clazz)
  2. isSerializable(final Object c)
  3. isSerializable(Object o)
  4. isSerializable(Object o)
  5. isSerializable(Object o)
  6. isSerializable(Object ob)
  7. isSerializable(Object obj)
  8. isSerializable(Object obj)
  9. isSerializable(Object object)