Decode Object
OSCore (O pen S ymphony Core) is a java library with lot of utilities and reusable components.
This requires the libraries oscore-2.2.6.jar, mail.jar to be in classpath.
The following example shows using TextUtils.decodeObject() API.
It decodes the Object encoded using TextUtils.encodeObject() API.
package com.bethecoder.tutorials.oscore;
import java.io.IOException;
import java.util.List;
import com.opensymphony.util.TextUtils;
public class DecodeObjectTest {
/**
* @param args
* @throws IOException
* @throws ClassNotFoundException
*/
public static void main ( String [] args ) throws IOException, ClassNotFoundException {
String str = ( String ) TextUtils.decodeObject ( "rO0ABXQAB0FCQ0RFRkc=" ) ;
System.out.println ( str ) ;
String encDoubleStr =
"rO0ABXNyABBqYXZhLmxhbmcuRG91YmxlgLPCSilr+wQCAAFEAAV2YWx1ZXhyABBqYXZhLmxhbmcu" +
"TnVtYmVyhqyVHQuU4IsCAAB4cD/zwMoqWx1d" ;
Double num = ( Double ) TextUtils.decodeObject ( encDoubleStr ) ;
System.out.println ( num ) ;
String encStrListStr =
"rO0ABXNyABpqYXZhLnV0aWwuQXJyYXlzJEFycmF5TGlzdNmkPL7NiAbSAgABWwABYXQAE1tMamF2" +
"YS9sYW5nL09iamVjdDt4cHVyABNbTGphdmEubGFuZy5TdHJpbmc7rdJW5+kde0cCAAB4cAAAAAJ0" +
"AANPTkV0AANUV08=" ;
List<String> strList = ( List<String> ) TextUtils.decodeObject ( encStrListStr ) ;
System.out.println ( strList ) ;
}
}
It gives the following output,
ABCDEFG
1.2345678
[ONE, TWO]