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)

解决方案 »

  1.   

    你用ethereal把用ie直接打开时发的包截下来,在这里把参数都设置上试试
      

  2.   

    奇怪,访问我的网页就行呀。import java.net.*;
    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());
    }
    }
      

  3.   

    http://www.6rooms.com/rss.php这个站点是否可用