示例
解决方案
使用
javax.mail.internet.MimeBodyPart.setDescription (String, String) 将使用指定的字符集来对给定的 Unicode 字符串进行编码。
注意,指定的字符集必须支持该字符串中的所有字符。
如果不知道该字符串使用的语言,那么使用 UTF-8。

public static void main(String[] args) {
String text = args[0];
String charset = args[1];
javax.mail.internet.MimeBodyPart mbp = new javax.mail.internet.MimeBodyPart();

try {
mbp.setDescription(text, charset);
byte[] description = mbp.getDescription().getBytes("UTF-8"); //$NON-NLS-1$
java.io.FileOutputStream out = new java.io.FileOutputStream(
"Rule182-2.html", true); //$NON-NLS-1$
out.write(description);

} catch (Exception e) {
System.out.println(e.toString());
}

}

public static void main(String[] args) {
javax.mail.internet.MimeBodyPart mbp = new javax.mail.internet.MimeBodyPart();
try {
mbp.setDescription(args[0]);
byte[] description = mbp.getDescription().getBytes();
java.io.FileOutputStream out = new java.io.FileOutputStream(
"Rule.html", true); //$NON-NLS-1$
out.write(description);
} catch (Exception e) {
System.out.println(e.toString());
}
}