user3548196
user3548196

Reputation: 375

Having issue reading a file from directory

I have csv file and when i try to read from the following code it throws an error FileNotFound. Can someone please suggest the solution for this.

    String csvFile = "spring/batch/report.csv";
    BufferedReader bufferReader = null;
    String line = "";
    String cvsSplitBy = ",";
    try {

        System.out.println("Job A has been started................");
        bufferReader = new BufferedReader(new FileReader(csvFile));
        while ((line = bufferReader.readLine()) != null) {

            // use comma as separator
            String[] country = line.split(cvsSplitBy);

            System.out.println("Country [code= " + country[4] + " , name="
                    + country[5] + "]");
        }

Upvotes: 0

Views: 32

Answers (1)

Jaya Dwivedi
Jaya Dwivedi

Reputation: 66

You need to provide the full path of csv file. Like

String csvFile = "C:/temp/abc.csv";

Upvotes: 1

Related Questions