Searching...
Wednesday, 23 April 2014

Serializing Objects to byte array using Apache SerializationUtils

11:02

1. Add below dependency

		<dependency>
			<groupId>commons-lang</groupId>
			<artifactId>commons-lang</artifactId>
			<version>2.3</version>
		</dependency>

2. Example

package com.pretech;
import org.apache.commons.lang.SerializationUtils;
public class SerializationExample {
	public static void main(String[] args) {
		byte name[] = SerializationUtils.serialize("Test");
		String deserilazed = (String) SerializationUtils.deserialize(name);
		System.out.println(deserilazed);
	}
}

3. Output



Test


0 comments: