从单个txt文件读取多个文件位置

问题描述 投票:-2回答:1

我有一个.txt文件,其中包含需要读取的所有500个XAML文件的位置和名称。

我必须在JAVA程序中使用.txt才能处理这些XAML文件。有人可以帮我提供代码吗?非常感谢。

java xml eclipse javac
1个回答
0
投票

这里是我快速执行的一些代码,我不知道它是否正是您想要的,但是它可用于从txt文件获取路径,然后从txt中指定的所有那些文件中读取信息。

BufferedReader br = new BufferedReader(new FileReader("path of your txt file"));
        String path;
        String string = " ";
        //reads all lines in .txt file
        BufferedReader reader;
        while((path = br.readLine()) != null) {
            //makes another buffered reader in the paths in the txt
            reader = new BufferedReader(new FileReader(path));
            while((string = reader.readLine()) != null) {
                //reads from file in path and prints to console
                System.out.println(string);
            }
        }
© www.soinside.com 2019 - 2024. All rights reserved.