Skip to content

Commit

Permalink
Add an open action to browse method. (#1234)
Browse files Browse the repository at this point in the history
  • Loading branch information
Omar122 authored Jan 2, 2025
1 parent 1729a1e commit 6daa05a
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ public static void main(String[] args) throws Exception {

public void browse(File file) throws IOException {
if (Desktop.isDesktopSupported()) {

Desktop.getDesktop().browse(file.toURI());
if (Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
Desktop.getDesktop().browse(file.toURI());
} else if (Desktop.getDesktop().isSupported(Desktop.Action.OPEN)) {
Desktop.getDesktop().open(file);
} else {
throw new UnsupportedOperationException("Neither open nor browse are supported");
}
} else {
throw new UnsupportedOperationException("Browser not supported.");
}
Expand Down

0 comments on commit 6daa05a

Please sign in to comment.