0
public class FIlesInAFolder {
private static BufferedReader br;
public static void main(String[] args) throws IOException {
File folder = new File("C:/filesexamplefolder");
FileReader fr = null;
if (folder.isDirectory()) {
for (File fileEntry : folder.listFiles()) {
if (fileEntry.isFile()) {
try {
fr = new FileReader(folder.getAbsolutePath() + "\\" + fileEntry.getName());
br = new BufferedReader(fr);
System.out.println(""+br.readLine());
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
finally {
br.close();
fr.close();
}
}
}
}
}
}
如何从目录的第一个文件打印第一个单词,从第二个文件打印第二个单词并从同一个目录的第三个文件打印第三个单词。如何从目录的文件中读取数据
i am able to open directory and print the line from each file of the directory,
but tell me how to print the first word from first file and second word from second file and so on . .
这并不容易从ditectory读取数据... – alfasin 2015-03-03 09:29:58
为每个文件 – gstackoverflow 2015-03-03 09:30:38
请修改以下问题http://stackoverflow.com/questions/14673063/merging-file-in-java创建不同的流 – gstackoverflow 2015-03-03 09:35:41