X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Finstantlauncher%2FUtils.java;h=7410bab5d670e4f0d8b13d3e7fda750cb6e3dab3;hb=d84757dc1d3555a22d9411970a6fa7efccf2619e;hp=297f0108966ce2e54b15df1153c124d0ebc3d35d;hpb=6f3b6383805ab24b835adaa7845e9306880ff7a3;p=instantlauncher.git diff --git a/src/main/java/eu/svjatoslav/instantlauncher/Utils.java b/src/main/java/eu/svjatoslav/instantlauncher/Utils.java index 297f010..7410bab 100755 --- a/src/main/java/eu/svjatoslav/instantlauncher/Utils.java +++ b/src/main/java/eu/svjatoslav/instantlauncher/Utils.java @@ -1,3 +1,7 @@ +/* + * Instantlauncher. Author: Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * This project is released under Creative Commons Zero (CC0) license. + */ package eu.svjatoslav.instantlauncher; import eu.svjatoslav.commons.gui.dialog.ExceptionDialog; @@ -19,19 +23,24 @@ public class Utils { } public static void runOpeningApplication(String commands, final File file) { - runOpeningApplication(commands.split("\\s+"), file); - } + try { + String[] commandsArray = commands.split("\\s+"); + for (int i=0; i< commandsArray.length; i++) + commandsArray[i] = commandsArray[i].replaceAll("\\{file\\}", file.getAbsolutePath()); - private static void runOpeningApplication(final String[] commands, final File file) { - for (int i = 0; i < commands.length; i++) - if (commands[i].equals(FILE_INDICATOR)) - commands[i] = file.getAbsolutePath(); + Runtime.getRuntime().exec(commandsArray); + } catch (final IOException e) { + new ExceptionDialog(e); + } + } + public static void executeCommand(String... c) { try { - Runtime.getRuntime().exec(commands); + Runtime.getRuntime().exec(c); } catch (final IOException e) { new ExceptionDialog(e); } } + }