笔记补录:
import java.io.UnsupportedEncodingException;
import sun.misc.BASE64Encoder;
class Demo
{
public static void main(String args[])throws Exception
{
test();
}
public static void test() throws UnsupportedEncodingException
{
BASE64Encoder en = new BASE64Encoder();
String s = en.encode(new String("字符串").getBytes("utf-8"));
System.out.println(s);
}
}
本文提供了一个使用Java进行BASE64编码的简单示例,通过sun.misc.BASE64Encoder类将UTF-8编码的字符串转换为BASE64格式。这是一个基本的编码实践,适用于初学者理解和应用。
9670

被折叠的 条评论
为什么被折叠?



