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

de.invation.code.toval.misc.SerializationUtils Maven / Gradle / Ivy

package de.invation.code.toval.misc;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

public class SerializationUtils {

	public static void serialize(Serializable object, String file) throws IOException {
		FileOutputStream fileOut = new FileOutputStream(file);
		ObjectOutputStream out = new ObjectOutputStream(fileOut);
		out.writeObject(object);
		out.close();
		fileOut.close();
	}

	public static Object deserialize(String file) throws IOException, ClassNotFoundException {
		FileInputStream fileIn = new FileInputStream(file);
		ObjectInputStream in = new ObjectInputStream(fileIn);
		Object result = in.readObject();
		in.close();
		fileIn.close();
		return result;

	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy