Modifier and Type | Method and Description |
---|---|
static void |
browse(URI uri)
Opens a browser for the given
URI . |
static String |
getHTMLFromFile(File file)
Returns the HTML text from a given file.
|
static String |
getHTMLFromURL(URL url)
Returns the HTML text from a given URL.
|
static String |
getHTMLFromXML(String xml,
File xsl)
Converts an XML file to a formatted HTML output via an XSLT definition.
|
static String |
getHTMLFromXML(String xml,
URL xsl)
Converts an XML file to a formatted HTML output via an XSLT definition.
|
static void |
saveToFile(File file,
String html)
Saves an HTML content to a given file.
|
public static void browse(URI uri)
URI
. It is supposed to avoid issues with KDE systems.uri
- URI to browsepublic static String getHTMLFromFile(File file)
Returns the HTML text from a given file. It is a wrapper method for getHTMLFromURL()
.
file
- A valid filepublic static String getHTMLFromURL(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 URLpublic static String getHTMLFromXML(String xml, File xsl)
xml
- String containing an XML filexsl
- File containing an XSLT definitionpublic static String getHTMLFromXML(String xml, URL xsl)
xml
- String containing an XML filexsl
- URL containing an XSLT definitionCopyright © 2018. All rights reserved.