openConnection()未定义 [英] openConnection() Not defined

查看:88
本文介绍了openConnection()未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




url.openConnection()的问题是未定义的,对java来说是完全新的,这里是我上网的示例代码:

< br $>


 HttpURLConnection connection = null; 
字符串 semifinalUrlString = http:// www.google.com /;
URL url = new URL(semifinalUrlString);
connection =(HttpURLConnection)url.openConnection();
connection.connect();







获取openConnection()我错过了什么?

解决方案

一个可能的原因可能是缺少正确的导入。必须有以下导入:

  import  java.io.BufferedReader; 
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;



欲了解更多信息可以在这里看一下讨论:

http://stackoverflow.com/questions/9977221/open-url-in-java-to-get-the-content [ ^ ]



Hope该问题将得到解决,如果没有,请用新的错误消息更新我们。感谢。


Hi
Problem with url.openConnection() is undefined and am completly new to java, here is a sample code i got online :


HttpURLConnection connection = null;       
		String semifinalUrlString = "http://www.google.com/";  
		URL url = new URL(semifinalUrlString);      
		connection = (HttpURLConnection)url.openConnection();      
		connection.connect(); 




What am I missing to get the openConnection()?

解决方案

One possible reason may be missing proper imports. There must be imports like:

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;


For more you can have a look on discussion here:
http://stackoverflow.com/questions/9977221/open-url-in-java-to-get-the-content[^]

Hope that issue will be resolved, if not please update us with new error message u get. Thanks.


这篇关于openConnection()未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆