程序 12-3
import java.net.URL;
import java.net.MalformedURLException;
import java.io.*;
class ReadFromURL{
public static void main(String args[]){
URL root = null;
URL url = null;
String readstring;
DataInputStream dis;
try{
root = new URL("file://10.93.121.28/program/chapter11/");
url = new URL(root,args[0]);

dis = new DataInputStream(url.openStream());
while((readstring = dis.readLine())!=null){
System.out.println(readstring);
}
System.out.println("***** end of the file *****");
dis.close();
}
catch(MalformedURLException e){
System.out.println("MalformedURLException,"+ e);
}
catch(IOException e){
System.out.println("IOException,"+ e);
}
}
}