在jar中读取多个文件

时间:2013-03-30 20:06:57

标签: java jar

我想在jar文件中读取多个文件。但它不起作用。它只读取一个文件并停止。我真的不明白InputstreamBufferedreader是如何运作的。这部分代码是从另一篇文章中借来的。

for (int i = 0; i < numList; i++) { // numList is number of file I want to read
     int fileNum = i + 1;
     String fileaddress = "List" + fileNum + ".txt";
     //All the files have name like "List1.txt", "List2.txt", etc
     InputStream configStream = getClass().getResourceAsStream(fileaddress);
     BufferedReader wordReader = new BufferedReader(new InputStreamReader(configStream, "UTF-8"));
     //the following is to store values in the line in an String array
     //add the array to an ArrayList called masterList
     String[] line;
     while((line = wordReader.readLine().split(": ")) != null){
     masterList.add(line);
}

0 个答案:

没有答案