Can we generate an .html doc using java? Usually we get ouput in cmd prompt wen we run java programs. I want to generate output in the form of .html or .doc format is their a way to do it in java?
For HTML
Just write data into .html file (they are simply text files with .html extension), using raw file io operation
For Example :
StringBuilder sb = new StringBuilder();
sb.append("<html>");
sb.append("<head>");
sb.append("<title>Title Of the page");
sb.append("</title>");
sb.append("</head>");
sb.append("<body> <b>Hello World</b>");
sb.append("</body>");
sb.append("</html>");
FileWriter fstream = new FileWriter("MyHtml.html");
BufferedWriter out = new BufferedWriter(fstream);
out.write(sb.toString());
out.close();
For word document
This thread answers it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With