开发者

Cannot open url connection

开发者 https://www.devze.com 2023-03-14 20:11 出处:网络
I have searched and looked and I cannot seem to find the source of my problem. I have code that is supposed to be taking a url, but for some reason no matter what I do. It seems to not be connected.

I have searched and looked and I cannot seem to find the source of my problem. I have code that is supposed to be taking a url, but for some reason no matter what I do. It seems to not be connected.

src = "http://ecx.images-amazon.com/images/I/410oAxun7dL._AA300_.jpg"
URL url = new URL(src);
URLConnection connection = (URLConnection) url.openConnection();
((HttpURLConnection) connection).s开发者_JAVA技巧etRequestMethod("GET");
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();

I get a java.net.SocketException: Permission denied error.

What is the cause of this error? And How would I fix it?

Thank you for your help!


I'm assuming you are trying to do this code in an Applet. That is not allowed, you will have to digitally sign your applet to get it to be allowed to access another server.


Could be a permissions issue on the folder? Make sure you can browse to the image via the browser.

0

精彩评论

暂无评论...
验证码 换一张
取 消