1

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

Bruno Lopes Bacelar
  • 115
  • 1
  • 2
  • 14

1 Answers1

4

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.

Alex Shesterov
  • 26,085
  • 12
  • 82
  • 103