|
||||||||||
PREV NEXT | FRAMES NO FRAMES |
See:
Description
Packages | |
---|---|
de.java2html | Main program package containing Java2Html application and applet. |
de.java2html.anttasks | |
de.java2html.commandline | |
de.java2html.converter | Classes for converting parsed Java source code to various output formats. |
de.java2html.gui | |
de.java2html.javasource | Classes for representing and parsing Java source code. |
de.java2html.options | |
de.java2html.plugin | |
de.java2html.plugin.jspwiki | |
de.java2html.properties | |
de.java2html.suite | |
de.java2html.util | |
de.tisje.java2html |
//Create a reader of the raw input text StringReader stringReader = new StringReader( "/** Simple Java2Html Demo */\r\n"+ "public static int doThis(String text){ return text.length() + 2; }"); //Parse the raw text to a JavaSource object JavaSource source = null; try { source = new JavaSourceParser().parse(stringReader); } catch (IOException e) { e.printStackTrace(); System.exit(1); } //Create a converter and write the JavaSource object as Html JavaSource2HTMLConverter converter = new JavaSource2HTMLConverter(source); StringWriter writer = new StringWriter(); try { converter.convert(writer); } catch (IOException e) { } System.out.println(writer.toString());The output of this program will look like this:
1 /** Simple Java2Html Demo */
|
The above example uses a java.io.StringReader
to read the raw text from and
a java.io.StringWriter
to write the output to. You may want to use
a java.io.FileReader
and/or a java.io.FileWriter
or
others instead.
//Get the default options and adjust it to your needs JavaSourceConversionOptions options = JavaSourceConversionOptions.getDefault(); options.setShowLineNumbers(false); options.getStyleTable().put( JavaSourceType.KEYWORD, new JavaSourceStyleEntry(Color.orange, true, false)); converter.setConversionOptions(options);
Conversion output:
/** Simple Java2Html Demo */
|
For a detailed description of the available options have a look at
JavaSourceConversionOptions
.
For a detailed description have a look at Java2Html
.
|
||||||||||
PREV NEXT | FRAMES NO FRAMES |