From f049f09e977da4ccd67d4b062c90658718fba87b Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Thu, 15 Nov 2018 22:38:51 +0100 Subject: [PATCH] Add functionality for opening generated html in a browser --- src/main/java/de/vanitasvitae/imi/codes/Main.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/de/vanitasvitae/imi/codes/Main.java b/src/main/java/de/vanitasvitae/imi/codes/Main.java index c0087c2..3d8f735 100644 --- a/src/main/java/de/vanitasvitae/imi/codes/Main.java +++ b/src/main/java/de/vanitasvitae/imi/codes/Main.java @@ -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) {