import sun.misc.BASE64Decoder;//将base64转换为byte[]
import sun.misc.BASE64Encoder;//转byet[]换为base64
public class Test {
public static void main(String args[]) throws IOException
{
//定义一个BASE64Encoder
BASE64Encoder encode = new BASE64Encoder();
//将byte[]转换为base64
String base64 = encode.encode("五笔字型电子计算机".getBytes());
//输出base64
System.out.println(base64);
//新建一个BASE64Decoder
BASE64Decoder decode = new BASE64Decoder();
//将base64转换为byte[]
byte[] b = decode.decodeBuffer(base64);
//输出转换后的byte[]
System.out.println(new String(b));
byte bhh[] = new byte[2];//去掉换行
bhh[0] = 13;
bhh[1] = 10;
String hchh = new String(bhh);
base64 = base64.replaceAll(hchh, "");
}
}