读写远程文件并显示

发表于:2007-07-04来源:作者:点击数: 标签:
import java.net.*;
import java.io.*;
import java.util.*;

public class ReadURLFile{

public static void main(String[] args) throws Exception{
URL urlfile = new URL("http://192.168.16.34/xuys/index_.html");
BufferedReader in = new BufferedReader(new InputStreamReader(urlfile.openStream()));

String content="";

String inputLine = in.readLine();
while(inputLine!=null){
content += inputLine;
inputLine = in.readLine();
}
System.out.println(content);
in.close();
}
}

原文转自:http://www.ltesting.net