を認証される必要があり、正常に動作します(JAVA)エラーは、私は、URLを開くには、このメソッドを使用してい
String osName = System.getProperty("os.name");
String url = "https://abcdefg.com";
try {
if (osName.startsWith("Windows")) {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
} else if (osName.startsWith("Mac OS X")) {
Runtime.getRuntime().exec("open " + url);
} else {
System.out.println("SO unsupported");
}
} catch (IOException e) {
System.out.println("Error opening " + url);
e.printStackTrace();
}
私の問題は、今私が入力しようとしているということですあなたが入力する前に認証する必要があるURL(これは私にエラー403を禁じます。あなたはこのサーバにアクセスする権限がありません)。質問は、私はURLを起動する前に認証することができるので、私はエラーが表示されません? (私はユーザー/パスを持っています) link to the image, I cant post them yet...
ありがとうございます!
PD:誰かがそれを求める前に、私は、この他の1は私に、このエラーを与えるため、URLを開くには、そのメソッドを使用します:接続リセット:P
try {
URL url = new URL("http://www.google.com");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
//InputStream is = url.openConnection().getInputStream();
//BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String line = null;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
in.close();
} catch (MalformedURLException e) {
System.out.println("MalformedURLException-> " + e);
} catch (IOException e) {
System.out.println("IOException-> " + e);
}
IOException-> java.net.SocketExceptionが
にしてくださいどのようにですか? – johnII