关于URL 不是,book_is_readLine()总等于-1 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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中,会有权限问题 你的程序没问题啊,能运行的……不过不清晰,看这个例子吧: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); } 我是在Intranet上的,不知是不是DNS的缘故,就是得不到内容 如何使用JProfile,新建一个session?? javamail的两个问题,求助指点 头痛的事务管理问题 重写clone()所带来的问题.java 谁有Acme.jar? 怎么判断用户按下ctrl+c,ctrl+v 请教JDBC的分类,工作原理及其区别! 如何将中文文件存入数据库?是文件,不是表单,谢谢!! 如何利用Canlender或Date类知道某年某月有几天 JAVA修改系统时间无权限 明日工作室(南京)电子技术有限公司 从JDK转到 JBuilder 的程序设计
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中,会有权限问题
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);
}