There are two types of threads in Java: user thread: user created thread; sprite thread: the thread running in the background and serving other threads; the garbage collector is sprite thread; when the JVM detects that there are only sprite threads, it will exit.
import java.net.*;
import java.io.*;
public class Javase_69
{
public static void main(String[] args)
{
String urlname = "http://www.edu.cn/index.html";
if (args.length>0) urlname=args[0];
new Javase_69().display(urlname);
}
public void display(String urlname)
{
try
{
URL url=new URL(urlname); //创建URL类对象url
InputStreamReader in=new InputStreamReader(url.openStream());
BufferedReader br=new BufferedReader(in);
String aLine;
while((aLine=br.readLine())!=null) //从流中读取一行显示
System.out.println(aLine);
}
catch(MalformedURLException murle)
{ System.out.println(murle); }
catch(IOException ioe)
{ System.out.println(ioe); }
}
}