1

I want to list all files of one directory. However, I can't find the files with the relative path. With the absolute path this works perfectly.

Here is my file structure:

My file structure

I have already set the static path and use it successfully with the css, and js files:

staticFiles.location("/public");
File f = new File("data/fJSON/f.json");
//File f = new File("C:\\Users\\user\\mS\\src\\main\\resources\\public\\data\\fJSON\\f.json");
try{
    BufferedReader br = new BufferedReader(new FileReader(f));
    String st;
    while ((st = br.readLine()) != null) {
        System.out.println(st);
    }
} catch (IOException e1) {
    e1.printStackTrace();
}

Note that the code should currently read only one specific file, which only works with the absolute path and not with the relative path.

What did I misconfigure or overlook about the path? What do I have to change so that the file can be read via the relative path?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
sebwr
  • 113
  • 1
  • 10

0 Answers0