Reputation: 375
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
Reputation: 66
You need to provide the full path of csv file. Like
String csvFile = "C:/temp/abc.csv";
Upvotes: 1