Base64.java file
Use the Base64 class to provide methods for Base64 encoding and decoding schemes.
package com.ibm.tamesso.utils;
import java.util.prefs.*;
import java.util.logging.*;
/**This class provides methods for Base-64 encoding and decoding
*/
public class Base64 {
private static final String CLASS = Base64.class.getName();
private static final Logger log=Logger.getLogger(CLASS);
/**This encodes a byte array into a Base-64 string
* @param array
* @return Base-64 encoded string
*/
public static String encode(byte[] array){
String methodName_ = "encode";
log.entering(CLASS, methodName_);
Preferences prefs = Preferences.userNodeForPackage(Base64.class);
prefs.putByteArray("key1",array);
log.exiting(CLASS,methodName_);
return prefs.get("key1", null);
}
/**This decodes a base-64 string into a byte array
* @param str
* @return byte array
*/
public static byte[] decode(String str){
String methodName_ = "decode";
log.entering(CLASS, methodName_);
Preferences prefs = Preferences.userNodeForPackage(Base64.class);
prefs.put("key2", str);
log.exiting(CLASS, methodName_);
return prefs.getByteArray("key2", null);
}
}