0

我正在使用可以从远程系统读取 .txt 文件的 struts 开发应用程序。我不知道该怎么做。有人可以建议一些例子来解释如何输入 URL 吗?它在http上。谢谢。

4

1 回答 1

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();
    }
}
于 2012-06-22T09:05:11.030 回答