我正在使用struts开发一个应用程序,它可以从远程系统读取.txt文件。我无法弄清楚如何做到这一点。有人可以建议一些例子,说明如何输入URL?它在http。感谢。
答案 0 :(得分:0)
试试这个
import java.net.*;
import java.io.*;
public class URLReader {
public static void main(String[] args) throws Exception {
// Here you need add copy file program which will copy file from c:/abc/abc.txt to your web project folder
URL oracle = new URL("http://www.demo.com/abc.txt");
BufferedReader in = new BufferedReader(
new InputStreamReader(oracle.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}