在java中怎么访问http的资源

zhaobohao 2004-09-17 04:01:37
如题,环境tomcat+unix.我在写一个class,需要在这个class中访问一个http的外部网页,例如:我现在要在java中访问http://www.sohu.com/list.jsp这个网页并且得到结果。我应该怎么做??谢谢大家
...全文
273 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
zhaobohao 2004-09-17
谢谢了。我对java的类不是很熟悉,听你这么一说, 我要去好好学习以下java的类报了。
回复
redlaputa 2004-09-17
HttpURLConnection huc=new HttpURLConnection("http://www.sohu.com/list.jsp");
String x=huc.getResponseMessage();
回复
redlaputa 2004-09-17
* Each HttpURLConnection instance is used to make a single request
* but the underlying network connection to the HTTP server may be
* transparently shared by other instances. Calling the close() methods
* on the InputStream or OutputStream of an HttpURLConnection
* after a request may free network resources associated with this
* instance but has no effect on any shared persistent connection.
* Calling the disconnect() method may close the underlying socket
* if a persistent connection is otherwise idle at that time.
*
* @see java.net.HttpURLConnection#disconnect()
* @since JDK1.1
*/
abstract public class HttpURLConnection extends URLConnection {
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2004-09-17 04:01
社区公告
暂无公告