Java Swing HTML plainToHtml(String plain)

Here you can find the source of plainToHtml(String plain)

Description

plain To Html

License

Open Source License

Declaration

public static String plainToHtml(String plain) 

Method Source Code


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

import java.io.ByteArrayInputStream;

import javax.swing.text.DefaultEditorKit;
import javax.swing.text.Document;

public class Main {
    public static String plainToHtml(String plain) {
        DefaultEditorKit plainParser = new DefaultEditorKit();
        Document document = plainParser.createDefaultDocument();
        try {//from   ww w  .ja va  2  s .c o m
            plainParser.read(new ByteArrayInputStream(plain.getBytes()), document, 0);
            String html = document.getText(0, document.getLength());
            return html;
        } catch (Exception e) {
            throw new RuntimeException("Error converting plain text to HTML", e);
        }
    }
}

Related

  1. htmlToPlain(String html)
  2. isUnderline(Element element)
  3. loadStyleSheet(URL url)
  4. makeStyleSheet(String name)
  5. nameOf(Element element)
  6. rtfToBody(String rtf)
  7. rtfToHtml(Reader rtf)
  8. rtfToHtml(String rtf)
  9. stripHTML(String html)