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 に答える