
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 HTML02HelloWorldSchreiben {

    public static void main(String[] args) {
        StringBuilder html = new StringBuilder();
        html.append("<html>\n");
        html.append("<body>\n");
        html.append("Hallo Welt!\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);
        }

    }

}
