credo di aver risolto, spulciando in rete ho trovato questi frammenti di codice, che al mmomento sembrano funzionare
codice:
// generate uri according to the filePath
private URI getFileURI(String filePath) {
URI uri = null;
filePath = filePath.trim();
if (filePath.indexOf("http") == 0 || filePath.indexOf("\\") == 0) {
if (filePath.indexOf("\\") == 0) {
filePath = "file:" + filePath;
filePath = filePath.replaceAll("#", "%23");
}
try {
filePath = filePath.replaceAll(" ", "%20");
URL url = new URL(filePath);
uri = url.toURI();
} catch (MalformedURLException ex) {
ex.printStackTrace();
} catch (URISyntaxException ex) {
ex.printStackTrace();
}
} else {
File file = new File(filePath);
uri = file.toURI();
}
return uri;
}
public void launchFile(File file) {
if (!Desktop.isDesktopSupported()) {
return;
}
Desktop dt = Desktop.getDesktop();
try {
dt.open(file);
} catch (IOException ex) {
// this is sometimes necessary with files on other servers ie
// \xxxxxx.xls
launchFile(file.getPath());
}
}
// this can launch both local and remote files
public void launchFile(String filePath) {
if (filePath == null || filePath.trim().length() == 0) {
return;
}
if (!Desktop.isDesktopSupported()) {
return;
}
Desktop dt = Desktop.getDesktop();
try {
dt.browse(getFileURI(filePath));
} catch (Exception ex) {
ex.printStackTrace();
}
}
}