Shaghayegh Tavakoli :
I'm trying to read a .csv file from my resource folder in my maven project. I've done it before like this:
BufferedReader reader = new BufferedReader(
new InputStreamReader(this.getClass().getResource("info.csv").openStream()));
CSVParser csvParser = new CSVParser(reader,
CSVFormat.DEFAULT.withFirstRecordAsHeader().withIgnoreHeaderCase().withTrim());
and it worked. and now in another project, I'm trying read my file from resources and I get NullPointerException.
The only thing that is different between these 2 projects is my packages.
This is for the one that works:
and This is the one that doesn't work:
What am I doing wrong?
Jens :
Add a slash before the filename:
new InputStreamReader(this.getClass().getResource("/info.csv").openStream()));
without slash it looks in the same directory structure than your class is located
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=473636&siteId=1