不是,
book_is_readLine()总等于-1

解决方案 »

  1.   

    import java.io.*;
    import java.net.*;
    public class UrlTest
    {
    public static void main(String args[])
    {
    try {
    URL bookURL=new URL( "http://www.cartoonfree.com/index_home.htm") ;
    URLConnection uc = bookURL.openConnection() ;
    String line_str;
    DataInputStream book_is;
    book_is=new DataInputStream(  uc.getInputStream() ) ;
    while((line_str=book_is.readLine())!=null)
    System.out.println(line_str);
    book_is.close();
    }
    catch(MalformedURLException mfURLe)
    {
    System.out.println("MalformedURLException:"+mfURLe);
    }
    catch(IOException ioe)
    {
      System.out.println("IOException:"+ioe);
    }
    }
    }
    没有问题,如果这段代码放在applet中,会有权限问题
      

  2.   

    你的程序没问题啊,能运行的……不过不清晰,看这个例子吧:
    try 
    {
      URL myURL=new URL( "http://www.cartoonfree.com/index_home.htm") ;
      BufferedReader bfr = new BufferedReader(new InputStreamReader(myURL.openStream()));
      String line = null;
      while ((line = bfr.readLine())!=null) System.out.println(line);
      bfr.close();
    }
    catch(Exception ex)
    {
      System.out.println(ex); 
    }
      

  3.   

    我是在Intranet上的,不知是不是DNS的缘故,就是得不到内容