String TemplateContent;
FileInputStream FileInputStream = new FileInputStream (FilePath);
int lenght = fileinputstream.available (); Available () returns the number of bytes that can be read from this file input stream without being blocked.
byte bytes[] = new Byte[lenght];
Fileinputstream.read (bytes); Read (byte[] b) reads up to b.length bytes of data from this input stream into a byte array.
Fileinputstream.close ();
TemplateContent = new String (bytes);
String title;
String content;
String author;
while (Rs.next ())
{
TemplateContent = new String (bytes); If you do not use this sentence, after the replacement, there is no #** #标志了 in TemplateContent. So to regenerate
title = rs.getstring ("title");
Content = rs.getstring ("content");
Author = rs.getstring ("author");
Out.println (title+ "********" +content+ "* * *" +author);
Out.print ("Below is the template content:<br>" +templatecontent+ "<br> below is the replacement HTML content <br>Templatecontent=templatecontent.replaceall ("#title #", title);
Templatecontent=templatecontent.replaceall ("#author #", author);//replace the corresponding place in the module
Templatecontent=templatecontent.replaceall ("#content #", content);
According to the time file name
Calendar calendar = Calendar.getinstance ();
String fileame = string.valueof (Calendar.gettimeinmillis ()) + ". html";
Fileame = Request.getrealpath ("/") + "html/" +fileame;//the generated Html file save path
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.