简体   繁体   中英

JAVA - Write into html files

I am looking to write inside an html file using java.

I have my index.html page ready and I would like to use this template and add a name list (with hyperlinks to go to their pages) at a certain place in this page. Is it possible to use beacons or tags to tell java to write to this exact location in the html file?

I will use this type of java code to write, the array will be a names array btw, but it's in this mind:

 String[] labelEquipment = { "thing1", "thing2", "thing3", "thing4", "thing5", "thing6", "thing7", "thing8", "thing9", "thing10" }; PrintWriter f0 = new PrintWriter(new FileWriter("filename.txt")); for (String string: labelEquipment) { f0.println(string); } f0.close();

You can create a html file like this:

<body>
{{my_placeholder}}
</body>

Using java, you can read this file as string and then use .replace('{{my_placeholder}}',your_content) to replace the place holder with individual label equipments. The variable your_content will have to be group of html tags that will be placed in your html in place of my_placeholder

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM