With the following Code I managed to open an URL with my external Browser (in my case - Firefox). Every URL open action creates a new tab and over time I have hundreds of tabs, which I want to prevent. I use this for a tool to visually check some dates in a webpage and when pressing next, it should show the next page in the same tab.
How do i achieve this ?
Code:
public static void openWebpage(URL url) {
try {
openWebpage(url.toURI());
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
public static void openWebpage(URI uri) {
Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(uri);
} catch (Exception e) {
e.printStackTrace();
}
}
}