Java Byte Array to Object deserialize(byte[] bytes)

Here you can find the source of deserialize(byte[] bytes)

Description

deserialize

License

Open Source License

Declaration

public static Object deserialize(byte[] bytes) throws IOException, ClassNotFoundException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.ByteArrayInputStream;

import java.io.IOException;
import java.io.ObjectInputStream;

import java.util.Base64;

public class Main {
    public static Object deserialize(byte[] bytes) throws IOException, ClassNotFoundException {
        // byte[] bytes = Base64.getDecoder().decode(data);
        ByteArrayInputStream in = new ByteArrayInputStream(bytes);
        ObjectInputStream is = new ObjectInputStream(in);
        return is.readObject();
    }/*from   w ww  .ja  v a  2s  .co  m*/

    public static Object deserialize(String data) throws IOException, ClassNotFoundException {
        byte[] bytes = Base64.getDecoder().decode(data);
        ByteArrayInputStream in = new ByteArrayInputStream(bytes);
        ObjectInputStream is = new ObjectInputStream(in);
        return is.readObject();
    }
}

Related

  1. deserialize(byte[] byteArray)
  2. deserialize(byte[] byteArray)
  3. deserialize(byte[] bytes)
  4. deserialize(byte[] bytes)
  5. deserialize(byte[] bytes)
  6. deserialize(byte[] bytes)
  7. deserialize(byte[] bytes)
  8. deserialize(byte[] bytes)
  9. deserialize(byte[] bytes)