public static void main(String[] args) {
StringBuilder stringHtml = new StringBuilder();
PrintStream printStream = null;
try{
printStream = new PrintStream(new FileOutputStream("E://test.html"));
}catch(FileNotFoundException e){
e.printStackTrace();
}
stringHtml.append("<html>");
stringHtml.append("<head>");
stringHtml.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
stringHtml.append("<title>TEST</title>");
stringHtml.append("</head>");
stringHtml.append("<body>");
stringHtml.append("<div>Hello,World!</div>");
stringHtml.append("</body>");
stringHtml.append("</html>");
try{
printStream.println(stringHtml.toString());
} catch (Exception e) {
e.printStackTrace();
} finally {
printStream.close();
}
}
Java后台创建html文件
最新推荐文章于 2024-08-05 04:37:18 发布