Skip to content

Instantly share code, notes, and snippets.

Created April 8, 2018 08:52
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save rieckpil/105477db9bde98649cb0274863214e17 to your computer and use it in GitHub Desktop.
Transfer .html to .xhtml with java
public class ToXHTML {
* <dependency>
* <groupId>net.sf.jtidy</groupId>
* <artifactId>jtidy</artifactId>
* <version>r938</version>
* </dependency>
private String convertToXhtml(String html) {
Tidy tidy = new Tidy();
ByteArrayInputStream inputStream = new ByteArrayInputStream(html.getBytes("UTF-8"));
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
tidy.parseDOM(inputStream, outputStream);
return outputStream.toString("UTF-8");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment