具体来说,我正在尝试从 SharePoint 打开一个文件,但它实际上只是一个网站,而且我有适当的访问权限,所以这不是问题。我正在尝试使用 java 中的桌面 api 打开它,但它给了我一条错误消息“文件不存在!” 桌面只能在本地工作吗?如果它确实适用于网站,我做错了什么?
基于 stephen c 的建议的新代码,它仍然无法正常工作。我错过了什么?
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) {
}
}
}
旧代码
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();
}
}
}