在java中怎么访问http的资源

zhaobohao 2004-09-17 04:01:37
如题,环境tomcat+unix.我在写一个class,需要在这个class中访问一个http的外部网页,例如:我现在要在java中访问http://www.sohu.com/list.jsp这个网页并且得到结果。我应该怎么做??谢谢大家
...全文
303 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
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 {

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧