如何将⼀段字符串转换为HTML格式
String text = "字符内容";
String htmlFileName = ateUUID()+".html";
String htmlPath = imgPath+ File.separatorChar+htmlFileName;
File file2 = new File(htmlPath);
StringBuilder sb = new StringBuilder();
try {
sb.append("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><title>Html Test</title> </head><body>");
sb.append("<div>");
sb.append(text);
sb.append("</div>");
html代码转链接sb.append("</body></html>");
PrintStream printStream = new PrintStream(new FileOutputStream(file2));
printStream.String());//将字符串写⼊⽂件
} catch (IOException e) {
code = 0;
e.printStackTrace();
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论