public class HTMLUtils
extends java.lang.Object
Auxiliary functions to work with HTML. The intended use is for reports
.
Modifier and Type | Class and Description |
---|---|
static class |
HTMLUtils.CustomHTMLEditorKit
Custom version of
HTMLEditorKit with an image cache. |
Constructor and Description |
---|
HTMLUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
exportToHTML(java.io.File file,
java.lang.String html)
Save a HTML content to a a given file.
|
static void |
exportToHTML(java.io.File file,
java.lang.String html,
java.util.Map<java.lang.String,java.awt.Image> images)
Save a HTML content to a a given file.
|
static java.lang.String |
getHTMLFromFile(java.io.File file)
Returns the HTML text from a given file.
|
static java.lang.String |
getHTMLFromURL(java.net.URL url)
Returns the HTML text from a given URL.
|
static java.lang.String |
includeNet2PlanHeader(java.lang.String html)
Includes a Net2Plan header to a HTML string.
|
public static java.lang.String includeNet2PlanHeader(java.lang.String html)
html
- HTML contentpublic static void exportToHTML(java.io.File file, java.lang.String html)
Save a HTML content to a a given file.
file
- A valid filehtml
- HTML contentpublic static void exportToHTML(java.io.File file, java.lang.String html, java.util.Map<java.lang.String,java.awt.Image> images)
Save a HTML content to a a given file.
Important: This method is for internal use, users should use the other exportToHTML
method.
file
- A valid filehtml
- HTML contentimages
- Map containing the image cache (URL -> Image)public static java.lang.String getHTMLFromFile(java.io.File file)
Returns the HTML text from a given file. It is a wrapper method for getHTMLFromURL()
.
file
- A valid filepublic static java.lang.String getHTMLFromURL(java.net.URL url)
Returns the HTML text from a given URL.
This method is intended for HTML files enclosed into the same JAR file as that enclosing the calling class. Therefore, the URL must point the location of the HTML file within that JAR file.
For example, assuming that a file named "example.html" is in the path "/aux-files/html" within the JAR file, then the calling would be as follows:
String html = HTMLUtils.getHTMLFromURL(getClass().getResource("/aux-files/html/examples.html").toURI().toURL());
Important: Image paths are converted to absolute paths.
url
- A valid URL