Where j2html save the HTML file?

885 Views Asked by At

I'm using j2html to create an HTML file in Java, it can be a fool question, but where does the file is saved?

1

There are 1 best solutions below

0
On

j2html gives you the following options:

Get rendered HTML as String:

String htmlString = TagCreator.html(...).render()

or

String htmlString = TagCreator.html(...).renderFormatted()

These methods return the rendered HTML as String, the HTML isn't written to any file.

Direct the rendered HTML to an Appendable (which can be a Writer):

For example,

    try (Appendable writer = new FileWriter("rendered.html")) {
        TagCreator.html(...).render(writer);
    }

would write the HTML into the rendered.html file.