当前位置:编程学习 > JSP >>

读写远程文件并显示

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

上一个:实例学习Spring和Hibernate的一点点体会
下一个:看看对话框

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,