@@ -32,18 +32,20 @@ public static boolean openFile(final String filePath) {
3232 final File file = new File (filePath );
3333 final Runtime rt = Runtime .getRuntime ();
3434
35- if (file .exists () && file .isFile ()) {
36- if (OS .isWindows ()) {
37- openFileWindows (rt , file );
38- } else if (OS .isLinux ()) {
39- openFileLinux (rt , filePath );
40- } else {
41- LOG .warn ("OS is not supported" );
42- }
43- return true ;
44- } else {
35+ if (!file .exists () || file .isFile ()) {
36+ LOG .warn ("Filepath does not seem to exist or does not point to a file: '{}'." , filePath );
4537 return false ;
4638 }
39+
40+ if (OS .isWindows ()) {
41+ openFileWindows (rt , file );
42+ } else if (OS .isLinux ()) {
43+ openFileLinux (rt , filePath );
44+ } else {
45+ // TODO implement for MAC
46+ LOG .warn ("OS '{}' is not supported" , OS .getOSName ());
47+ }
48+ return true ;
4749 }
4850
4951 private static void openFileWindows (final Runtime rt , final File file ) {
@@ -52,7 +54,7 @@ private static void openFileWindows(final Runtime rt, final File file) {
5254 LOG .debug ("executing command: {}" , command );
5355 rt .exec (command );
5456 } catch (final Exception e ) {
55- LOG .error ("Could not open file '" + file + " ' with command '" + command + "'." , e );
57+ LOG .error ("Could not open file '{} ' with command '{}'." , file , command , e );
5658 }
5759 }
5860
@@ -64,7 +66,8 @@ private static void openFileLinux(final Runtime rt, final String filePath) {
6466 LOG .debug ("executing command: {}" , Arrays .toString (command ));
6567 rt .exec (command );
6668 } catch (final Exception e ) {
67- LOG .error ("Could not open file '" + filePath + "' with command '" + Arrays .toString (command ) + "'." , e );
69+ LOG .error ("Could not open file '{}' with command '{}'." , filePath , Arrays .toString (command ),
70+ e );
6871 }
6972 }
7073}
0 commit comments