Java Is Serializable Object isSerializable(Object o)

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

Description

is Serializable

License

Apache License

Declaration

public static boolean isSerializable(Object o) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.*;

public class Main {
    public static boolean isSerializable(Object o) throws IOException {
        if (!(o instanceof Serializable)) {
            return false;
        }//from  w w w. j a v a2s .  c  o m
        try {
            // Let's test to make sure, the object may consist of an object that is not serializable
            new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(o);
            return true;
        } catch (NotSerializableException nse) {
            return false;
        }
    }
}

Related

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