Choose an "x" file inside a directory in java

1
So I'm doing a project and in it I would have to fetch some keywords in .txt files within a certain directory, except that the name of those files does not follow a pattern and my program would have to read 1 by 1. I would like to know if there is any method in Java that can select a file based only on its directory and the position in which it is in it, for example "find the path of the 3 file in the folder such"

    
asked by anonymous 15.05.2017 / 16:25

1 answer

0
public static void getImgs(String path){
File file = new File(path); // Diretório dos arquivos
File[] arquivos = file.listFiles();

for (File arquivo : arquivos) {
    System.out.println(arquivo); // Exibe o nome dos arquivos no diretório determinado
}
}
    
15.05.2017 / 16:36