Add functionality for opening generated html in a browser

This commit is contained in:
Paul Schaub 2018-11-15 22:38:51 +01:00
parent 866f4aa6a3
commit f049f09e97
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -1,9 +1,12 @@
package de.vanitasvitae.imi.codes;
import java.awt.*;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import de.vanitasvitae.imi.codes.input.Arguments;
@ -91,6 +94,14 @@ public class Main {
String html = new HtmlTableStringBuilder("IMI Sample Tube Code Generator", codes).toString();
writeHtml(html, outputPath);
if (externalBrowser && Desktop.isDesktopSupported()) {
try {
Desktop.getDesktop().browse(new URI("file://" + outputPath.getAbsolutePath()));
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
}
}
private static void writeHtml(String html, File destination) {