All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.icodegarden.nutrient.lang.serialization.JavaDeserializer Maven / Gradle / Ivy

There is a newer version: 3.0.2
Show newest version
package io.github.icodegarden.nutrient.lang.serialization;

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

/**
 * 
 * @author Fangfang.Xu
 *
 */
public class JavaDeserializer implements Deserializer {

	@Override
	public Object deserialize(byte[] bytes) throws SerializationException{
		try (ObjectInputStream objectInputStream = new ObjectInputStream(new ByteArrayInputStream(bytes));) {
			return objectInputStream.readObject();
		} catch (IOException | ClassNotFoundException e) {
			throw new SerializationException("Error when deserializing byte[] to object", e);
		}
	}
}