public static void main(String[] args) throws Exception{
URL u = new URL("http://www.6rooms.com/rss.php");
URLConnection con = u.openConnection();
StringBuffer sb = new StringBuffer(); InputStreamReader reader = new InputStreamReader(con.getInputStream());
int c = 0;
while((c = reader.read()) != -1) {
sb.append((char)c);
}
System.out.println(sb.toString());
}
为什么会跑这个错误呢
Exception in thread "main" java.io.FileNotFoundException: http://www.6rooms.com/rss.php
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at com.Rss.main(Rss.java:15)
URL u = new URL("http://www.6rooms.com/rss.php");
URLConnection con = u.openConnection();
StringBuffer sb = new StringBuffer(); InputStreamReader reader = new InputStreamReader(con.getInputStream());
int c = 0;
while((c = reader.read()) != -1) {
sb.append((char)c);
}
System.out.println(sb.toString());
}
为什么会跑这个错误呢
Exception in thread "main" java.io.FileNotFoundException: http://www.6rooms.com/rss.php
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at com.Rss.main(Rss.java:15)
解决方案 »
- 匹配一个正则表达式,在线等
- java写文件问题
- 在jbuilder X 中使用jtable 出现的问题!!!
- 基于j2ee的OA系统(项目日记)
- 请多指教get connection from datasource fail : Cannot create JDBC driver of class '' for connect URL 'null'
- 奇怪的问题,困扰了我好久,存储过程的返回值是Null,大虾进来看看!
- 那位高手能帮我解决一下关于调用的问题
- 高分求解:用java怎么扫描端口?一定给分
- 求教高手struts开发中遇到的问题
- 请教返回方法的类型问题.
- 问个类路径的问题
- java如果调用window的dll?
import java.io.*;
public class Test
{
public static void main(String[] args) throws Exception{
URL u = new URL("http://huliangyu.blog.com.cn/archives/2006/1560126.shtml");
InputStream in=u.openStream();
InputStreamReader reader = new InputStreamReader(in);
int c = 0;
while((c = reader.read()) != -1) {
sb.append((char)c);
}
System.out.println(sb.toString());
}
}