具體而言,我試圖從SharePoint打開一個文件,但它實際上只是一個網站,我有適當的訪問權限,因此'不是問題。我試圖在java中使用桌面API來打開它,但它給了我一個錯誤消息「文件不存在!」桌面只能在本地使用嗎?如果它對網站有效,我做錯了什麼?從java中的一個網站打開一個文件
基於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();
}
}
}
所以你可以告訴我一個如何在代碼中使用它的例子! – jerhynsoen
@ jerhynsoen - 請參閱我的答案,以獲得將解釋這一切的教程鏈接。 –
看起來,真的很複雜...... – jerhynsoen