The following method can be used to output the desired file, depending on the situation. I will take the output html as an example below.
// Html Template
<Html>
<Head> <title> </Html>
<Body>
<Div >### content ###"
### Ccc ###
</Div>
</Body>
</Html>
// ------------------------------------------- End of the template k.html
File foutt = new File ("D: \ Nworkspace \ ytcms \ WebRoot \ html \ zs \ z.html"); // path of the output File
File finput = new File ("D :\\ Nworkspace \ ytcms \ WebRoot \ html \ zs \ k.html"); // read the File template path
String templateContent = "";
Try {
// Read the object [input file]
FileInputStream fiut = new FileInputStream (finput );
InputStreamReader iReader = new InputStreamReader (fiut, "UTF-8 ");
StringBuffer sb1 = new StringBuffer ();
While (iReader. ready ()){
Sb1.append (char) iReader. read ());
}
TemplateContent = sb1.toString (). replaceAll ("### content ###", "what is this "). replaceAll ("### ccc ###", "This is step on ");
System. out. println (templateContent );
IReader. close ();
Fiut. close ();
// Write a file [output file]
FileOutputStream fout = new FileOutputStream (foutt );
OutputStreamWriter oWriter = new OutputStreamWriter (fout, "UTF-8 ");
OWriter. append (templateContent );
OWriter. close ();
Fout. close ();
} Catch (FileNotFoundException e ){
// TODO automatically generates catch Blocks
E. printStackTrace ();
} Catch (UnsupportedEncodingException e ){
// TODO automatically generates catch Blocks
E. printStackTrace ();
} Catch (IOException e ){
// TODO automatically generates catch Blocks
E. printStackTrace ();
}