
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;


public class HTML06Tabelle {

    public static void main(String[] args) {
        StringBuilder html = new StringBuilder();
        html.append("<html>\n");
        html.append("<body>\n");

        html.append("<table border=1>\n");


        int maxZeile=10, maxSpalte=5;
        for (int z = 0; z < maxZeile; z++) {
        html.append("<tr>\n");
        for (int s = 0; s < maxSpalte; s++) {
            //html.append("<span style='color: rgb(123,23,1)'>Hallo Welt!</span>\n");
            int farbe1 = (int)(Math.random()*256);
            int farbe2 = (int)(Math.random()*256);
            int farbe3 = (int)(Math.random()*256);
            
            html.append("<td style='background-color: rgb("+farbe1+","+farbe2+","+farbe3+")'>\n");
            html.append("<span >"+farbe1+"</span>\n");            
            html.append("</td>\n");            
        }                  
        html.append("</tr>\n");
        }
        html.append("</body>\n");
        html.append("</html>\n");
        System.out.println(html.toString());

        // Datei schreiben
        String filename = "tabelle.html";
        boolean append = false;
        try {
            FileWriter file = new FileWriter(filename, append);
            BufferedWriter buff = new BufferedWriter(file);
            PrintWriter out = new PrintWriter(buff);
            out.println(html.toString());
            out.flush();
            out.close();

            //Firefox starten
            new ProcessBuilder("cmd", "/c", "start", "/B", filename).start();

        } catch (IOException e) {
            System.out.println("Error:" + e);
        }

    }
    
}
