Bil*_*llu 1 html java fonts swing jtable
我使用Bamini字体在JTable中显示tamil字体.它工作正常并显示泰米尔语字体.但是当我单击"打印"按钮时,它应该生成HTML格式化输出.但如果我正在使用,
StringBuffer out = new StringBuffer();
out.append("<html><body>");
out.append(jTable1.getValueAt(0, 0));
out.append("??????????");
out.append("</body></html>");
try {
Writer out1 = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("F:/hello.html"), "UTF-8"));
out1.write(out.toString());
out1.close();
} catch (IOException ex) {
Logger.getLogger(tabletest.class.getName()).log(Level.SEVERE, null, ex);
}
Run Code Online (Sandbox Code Playgroud)
意味着它只显示一些不需要的垃圾字符而不是泰米尔字符.我怎样才能做到这一点?我的HTML文件的输出是,

这里的காஷ்மீரில்是从其他网站复制的.它向我展示了垃圾人物.JTable的内容显示其实际英文字符未转换字符.
现代HTML文件的基本结构如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Some Title</title>
</head>
<body>
Some contents
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
因此,您的代码应更正为:
StringBuffer out = new StringBuffer();
out.append("<!DOCTYPE html><html><head><meta charset=\"utf-8\" /><title>Some Title</title></head><body>");
out.append(jTable1.getValueAt(0, 0));
out.append("??????????");
out.append("</body></html>");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
567 次 |
| 最近记录: |