Specifically I am trying to open a file from SharePoint, but it’s really just a website, and I have the proper access so that’ not an issue. I am trying to use the desktop api in java to open it, but it gives me an error message “File does not exist!” Does desktop only work locally? If it does work for websites, what am I doing wrong?
new code based on stephen c’s suggesttions, it still does not work however. What am I missing?
public class ParseURL {
public static void main(String[] args) throws Exception {
try {
URL url = new URL("http://wss/is/sites/itsd/network/Remote%20Access/Soft%20Tokens/Your%20new%20RSA%20Soft%20Token%20for%20Android%20-%20INC%20XXXXXXX.oft");
InputStream is = url.openStream();
is.close();
} catch(IOException err) {
}
}
}
old code
public static void main(){
try {
File oftFile = new File("http://wss/is/sites/itsd/network/Remote%20Access/Soft%20Tokens/Your%20new%20RSA%20Soft%20Token%20for%20Android%20-%20INC%20XXXXXXX.oft
");
if (oftFile.exists()) {
if (Desktop.isDesktopSupported()) {
Desktop.getDesktop().open(oftFile);
} else {
System.out.println("Awt Desktop is not supported!");
}
} else {
System.out.println("File does not exist!");
}
System.out.println("Done");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Try using HttpURLConnection.
This is a web address and you need to connect to the url and read the contents from the stream you get from the connection.
See Usage here