使用java读取URL
import java.net.*;
import java.io.*;
public class ReadDemo
{
public static void main(String argv[])
{
try
{
URL url = new URL("http://blog.chinaunix.net/u/15586/showart_1863289.html");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String str;
while((str = in.readLine()) != null)
System.out.println(str);
in.close();
}
catch(MalformedURLException e){}
catch(IOException e) {}
}
}
本文来自: (www.91linux.com) 详细出处参考:http://www.91linux.com/html/article/program/java/20090314/16092.html
相关文档:
Java学习从入门到精通
一、 JDK (Java Development Kit)
JDK是整个Java的核心,包括了Java运行环境(Java Runtime Envirnment),一堆Java工具和Java基础的类库(rt.jar)。不论什么Java应用服务器实质都是内置了某个版本的JDK。因此掌握JDK是学好Java的第一步。最主流的J ......
一 相对路径的获得
说明:相对路径(即不写明时候到底相对谁)均可通过以下方式获得(不论是一般的java项目还是web项目)
String relativelyPath=System.getProperty("user.dir");
上述相对路径中,java项目中的 ......
package innerClass.test;
public class InheritTest
{
public static void main(String[] args)
{
Person p = new Person("LMS");
p.show();
  ......
1. 首先String不属于8种基本数据类型,String是一个对象。
因为对象的默认值是null,所以String的默认值也是null;但它又是一种特殊的对象,有其它对象没有的一些特性。
2. new String()和new String(“”)都是申明一个新的空字符串,是空串不是null;
3. String str=”kvill”;
String str=n ......