GokuaiBase/src/main/java/com/gokuai/base/utils/Base64.java
public static String encodeObject(java.io.Serializable serializableObject, int options) throws IOException {

		if (serializableObject == null) {
			throw new NullPointerException("Cannot serialize a null object.");
		} // end if: null

		// Streams
		java.io.ByteArrayOutputStream baos = null;
		java.io.OutputStream b64os = null;
		java.util.zip.GZIPOutputStream gzos = null;
		java.io.ObjectOutputStream oos = null;

		try {
			// ObjectOutputStream -> (GZIP) -> Base64 -> ByteArrayOutputStream
			baos = new java.io.ByteArrayOutputStream();
			b64os = new Base64.OutputStream(baos, ENCODE | options);
			if ((options & GZIP) != 0) {
				// Gzip
				gzos = new java.util.zip.GZIPOutputStream(b64os);
				oos = new java.io.ObjectOutputStream(gzos);
			} else {
				// Not gzipped
				oos = new java.io.ObjectOutputStream(b64os);
			}
			oos.writeObject(serializableObject);
		} // end try
		catch (IOException e) {
			// Catch it and then throw it immediately so that
			// the finally{} block is called for cleanup.
			throw e;
		} // end catch
		finally {
			try {
				oos.close();
			} catch (Exception e) {
			}
			try {
				gzos.close();
			} catch (Exception e) {
			}
			try {
				b64os.close();
			} catch (Exception e) {
			}
			try {
				baos.close();
			} catch (Exception e) {
			}
		} // end finally

		// Return value according to relevant encoding.
		try {
			return new String(baos.toByteArray(), PREFERRED_ENCODING);
		} // end try
		catch (java.io.UnsupportedEncodingException uue) {
			// Fall back to some Java default
			return new String(baos.toByteArray());
		} // end catch

	}
/**
	 * Encode object.
	 *
	 * @param serializableObject
	 *            the serializable object
	 * @param options
	 *            the options
	 *
	 * @return the string
	 *
	 * @throws IOException
	 *             Signals that an I/O exception has occurred.
	 */
Encode object.
@param serializableObject
the serializable object
@param options
the options

@return the string

@throws IOException
Signals that an I/O exception has occurred.
Encode object . @param serializableObject the serializable object @param options the options @return the string @throws IOException Signals that an I / O exception has occurred .
public static String encodeObject(java.io.Serializable serializableObject, int options) throws IOException {
		if (serializableObject == null) {
			throw new NullPointerException("Cannot serialize a null object.");
		} 
		java.io.ByteArrayOutputStream baos = null;
		java.io.OutputStream b64os = null;
		java.util.zip.GZIPOutputStream gzos = null;
		java.io.ObjectOutputStream oos = null;
		try {
			baos = new java.io.ByteArrayOutputStream();
			b64os = new Base64.OutputStream(baos, ENCODE | options);
			if ((options & GZIP) != 0) {
				gzos = new java.util.zip.GZIPOutputStream(b64os);
				oos = new java.io.ObjectOutputStream(gzos);
			} else {
				oos = new java.io.ObjectOutputStream(b64os);
			}
			oos.writeObject(serializableObject);
		} 
		catch (IOException e) {
			throw e;
		} 
		finally {
			try {
				oos.close();
			} catch (Exception e) {
			}
			try {
				gzos.close();
			} catch (Exception e) {
			}
			try {
				b64os.close();
			} catch (Exception e) {
			}
			try {
				baos.close();
			} catch (Exception e) {
			}
		} 
		try {
			return new String(baos.toByteArray(), PREFERRED_ENCODING);
		} 
		catch (java.io.UnsupportedEncodingException uue) {
			return new String(baos.toByteArray());
		} 
	}
public static String encodeObject ( java . io . Serializable serializableObject , int options ) throws IOException { if ( serializableObject == null ) { throw new NullPointerException ( "Cannot serialize a null object." ) ; } java . io . ByteArrayOutputStream baos = null ; java . io . OutputStream b64os = null ; java . util . zip . GZIPOutputStream gzos = null ; java . io . ObjectOutputStream oos = null ; try { baos = new java . io . ByteArrayOutputStream ( ) ; b64os = new Base64 . OutputStream ( baos , ENCODE | options ) ; if ( ( options & GZIP ) != 0 ) { gzos = new java . util . zip . GZIPOutputStream ( b64os ) ; oos = new java . io . ObjectOutputStream ( gzos ) ; } else { oos = new java . io . ObjectOutputStream ( b64os ) ; } oos . writeObject ( serializableObject ) ; } catch ( IOException e ) { throw e ; } finally { try { oos . close ( ) ; } catch ( Exception e ) { } try { gzos . close ( ) ; } catch ( Exception e ) { } try { b64os . close ( ) ; } catch ( Exception e ) { } try { baos . close ( ) ; } catch ( Exception e ) { } } try { return new String ( baos . toByteArray ( ) , PREFERRED_ENCODING ) ; } catch ( java . io . UnsupportedEncodingException uue ) { return new String ( baos . toByteArray ( ) ) ; } }
Encode object.
Encode object .
// end if: null // Streams // ObjectOutputStream -> (GZIP) -> Base64 -> ByteArrayOutputStream // Gzip // Not gzipped // end try // Catch it and then throw it immediately so that // the finally{} block is called for cleanup. // end catch // end finally // Return value according to relevant encoding. // end try // Fall back to some Java default // end catch