How can I read a path from .txt in java

I have a txt file. This contains a directory (H: /). I want to read this directory. There are also a few csv files in the directory. I would like to see only the csv-files. My Java code contains everything relevant, I think. Now he does not find the text file. The text file is located in the project folder in Eclipse (so I used a relative path)
Where is my mistake?

EDIT: I make a common example of my problem

public class AllFiles {

public static void main(String[]args) throws IOException
    File dir = new File("C:/Users/Example/Main/Test.txt");

} private static void getAllFiles(File dir) throws IOException {

    // Read from the file
    BufferedReader br = new BufferedReader(new FileReader(dir));
    String path  = br.readLine();

    File[] fileArray = new File (line).listFiles(new FilenameFilter() {  
        //only data with .csv were shown
        public boolean accept(File dir, String name) {
            return name.endsWith(".csv");

    for(File f : fileArray){


You never assign the content of the file to the variable line.

Change String line;
br.readLine(); to String line = br.readLine();

The next error is that you are try to list files from “…/Users/example/Test.txt”. Whyt you want to try is:

File[] fileArray = new File(line).listFiles(...