Java读取远程文件并显示

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();	
	}
}

你可能感兴趣的:(url,bufferedreader,远程读取文件)