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

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author bal
 */
public class HTML05HelloWorldSchleife {

    public static void main(String[] args) {
        StringBuilder html = new StringBuilder();
        html.append("<html>\n");
        html.append("<body>\n");
        for (int i = 0; i < 1000; i++) {
            //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("<span style='color: rgb("+farbe1+","+farbe2+","+farbe3+")'>Hallo Welt!</span>\n");            

        }        
        html.append("</body>\n");
        html.append("</html>\n");
        System.out.println(html.toString());

        // Datei schreiben
        String filename = "test.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);
        }

    }

}
