Skip to content

Commit

Permalink
Add webBrowse(String link) method
Browse files Browse the repository at this point in the history
  • Loading branch information
awidesky committed May 7, 2021
1 parent 8ecf57b commit 6d75c78
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/com/awidesky/YoutubeClipboardAutoDownloader/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,4 +366,26 @@ public static void kill(int exitcode) {

}


public static void webBrowse(String link) {

try {
if(Desktop.isDesktopSupported()) {
Desktop.getDesktop().browse(new URI(link));
} else {
try {
Runtime.getRuntime().exec("xdg-open " + link);
} catch (IOException e) {
throw new IOException("Desktop.isDesktopSupported() is false and xdg-open doesn't work");
}
}

} catch (IOException e) {
GUI.warning("Cannot open default web browser!", "Please visit" + link + "\n%e%", e);
} catch (URISyntaxException e) {
GUI.error("Invalid url!", link + "\n%e%", e);
}

}

}

0 comments on commit 6d75c78

Please sign in to comment.