0

I get this error when trying to run my command-line application which reads data from a given csv file. The filename is "data.csv" and should not be hardcoded. Here is my code:

Map<Integer,String[]> map= new HashMap<>();
    public Coursework(String filename) {
        try{
            // System.out.println(filename);
            String splitBy = ",";
            BufferedReader br = new BufferedReader(new FileReader(filename));
            String line;
            while((line = br.readLine()) != null) {
                // System.out.println(line);
            String[] b = line.split(splitBy);

                if(b[0].equals("id")){
                    continue;
                }
                // System.out.println("hello");
                int id = Integer.parseInt(b[0]);
                map.put(id,b);
            }
            br.close();
            // System.out.println("success");
        }
        catch(Exception e){
            System.out.println(e);
        }
    }
  • 1
    Does this answer your question? [How to get the current working directory in Java?](https://stackoverflow.com/questions/4871051/how-to-get-the-current-working-directory-in-java) – Lei Yang Mar 14 '22 at 11:13
  • If you uncomment ` System.out.println(filename)` can you copy paste the file name which is printed out in terminal when in the directory of the Java .class or .jar file? ( With cat or type for example) –  Mar 14 '22 at 11:32

0 Answers0