Java HTML to Text toHtmlByHtml(String html)

Here you can find the source of toHtmlByHtml(String html)

Description

insert html tag in the top
Beware: It's include head and body tag too
 input: 
I am Java programmer
output:
I am Java programmer
The output, can managing by #newOutputSetting(Document.OutputSettings)

License

Open Source License

Parameter

Parameter Description
html input html

Return

input with html, body and head tag

Declaration

public static Element toHtmlByHtml(String html) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.jsoup.nodes.Element;

public class Main {
    /**//from   ww w  . j a  v a  2s .c om
     * insert html tag in the top <br>
     * <b>Beware</b>: It's include head and body tag too
     * <pre>{@code
     * input: <div>I am <code>Java</code> programmer</div>
     * output:
     * <html>
     *      <head></head>
     *      <body>
     *          <div>I am <code>Java</code> programmer</div>
     *      </body>
     * </html>
     * }</pre>
     * <b>The output, can managing by {@link #newOutputSetting(Document.OutputSettings)}</b>
     *
     * @param html
     *       input html
     * @return input with html, body and head tag
     */
    public static Element toHtmlByHtml(String html) {
        return new Element("html").append(html);
    }
}

Related

  1. html2text(String htmlStr)
  2. text(Element e)
  3. text(Element element)
  4. textOf(final Element el)
  5. toElement(String html)
  6. toHtmlByPlain(String plainText)