Netbeans IDE で Java アプレットを作成しました。私のアプレットはhtmlファイルを作成します。それには文字列が含まれます。
//Other code
File htmlTemplateFile = new File("template.html");
String htmlString = FileUtils.readFileToString(htmlTemplateFile);
String title = "Title";
htmlString = htmlString.replace("$title", title);
File newTextFile = new File("paragraph.txt");
FileUtils.write(newTextFile, "Contents", "UTF-8");
FileWriter pw = new FileWriter(newTextFile);
pw.write("Δεῦτε");
pw.close();
String paragraph = new Scanner( new File("paragraph.txt") ).useDelimiter("\\A").next();
htmlString = htmlString.replace("$paragraph", paragraph);
File newHtmlFile = new File("example.html");
FileUtils.writeStringToFile(newHtmlFile, htmlString);
私のtemplate.htmlは次のとおりです。
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>$title</title>
</head>
<body>
<p>$paragraph
</p>
</body>
</html>
Netbeans から実行し、example.html ファイルを開いたときに作成すると、
私のブラウザでは Δεῦτε (古代ギリシャ文字) ですが、applet.jar を作成して .jar を実行すると、同じ example.html ファイルが作成されますが、ブラウザで開くと、次のようなものが表示されます。
xC4xE5?xF4xE5
一部の未読文字。