/* * [ToHTML.java] * * Summary: Converts a Property Table to a sorted HTML table for debugging. Output is to the console. * * Copyright: (c) 2000-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 2.2 2008-04-06 add build to title, tidy code, fix spelling errors. */ package com.mindprod.esper; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.Properties; import static java.lang.System.*; /** * Converts a Property Table to a sorted HTML table for debugging. Output is to the console. * * @author Roedy Green, Canadian Mind Products * @version 2.2 2008-04-06 add build to title, tidy code, fix spelling errors. * @since 2000 */ public final class ToHTML { /** * public constructor * * @param dictName name of dictionary on disk. * @param leftColour name of colour for the from language * @param rightColour name of colour for the to language */ private ToHTML( String dictName, String leftColour, String rightColour ) { final Properties h = new Properties(); try { final InputStream is = new FileInputStream( dictName ); // load entire dictionary into RAM h.load( is ); is.close(); } catch ( IOException e ) { // just have an empty dictionary return; } out.println( "

" + "\n" + "\n" ); final String[] allKeys = new String[ h.size() ]; // Properties are not generifiable int i = 0; for ( Object o : h.keySet() ) { allKeys[ i++ ] = ( String ) o; } Arrays.sort( allKeys ); for ( String left : allKeys ) { String right = ( String ) h.get( left ); out.println( "\n" ); } out.println( "
Translation
" + left + "" + right + "
\n" ); } /** * @param args name of Property file, left colour, right colour e.g. vortaro.dict brown blue */ public static void main( String[] args ) { new ToHTML( args[ 0 ], args[ 1 ], args[ 2 ] ); } } // end toHTML