範例

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

解決方案
使用
javax.mail.internet.MimeBodyPart.setDescription (java.lang.String, java.lang.String)
給定的 Unicode 字串將以指定的字集來編碼。
請注意,指定的字集必須支援字串中的所有字元。
如果字串的語言未知,請使用 UTF-8。

public static void main(String[] args) {
String text = args[0];
String charset = args[1];
javax.mail.internet.MimeMessage mm = new javax.mail.internet.MimeMessage(
java.mail.Session.getInstance(new java.util.Properties()));

try {
mm.setDescription(text, charset);
byte[] description = mm.getDescription().getBytes("UTF-8"); //$NON-NLS-1$
java.io.FileOutputStream out = new java.io.FileOutputStream(
"Rule185-2.html", true); //$NON-NLS-1$
out.write(description);
} catch (Exception e) {
System.out.println(e.toString());
}
}