I'm trying to write a static function that reads a CSV and output a value from that said CSV. I'm having trouble reading it because every time I get a fileNotFound exeception, however I believe my path is correct.
Here's the code
public class DateFormatUtils {
private static String dateFormatCsvPath = "csv/country_date_format.csv";
public static String getDateFormatByLocale(Locale Locale) {
List<Map<String, String>> mapList = Collections.emptyList();
String fileExtension = "csv";
try {
InputStream inputStream = new FileInputStream(dateFormatCsvPath);
mapList = ExcelUtils.read(inputStream, fileExtension);
String a = "a";
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return "a";
}
}
Here's a screenshot of my project, you can see that relatively from my class, the file is under csv/country_date_format.csv
. I also tried ./csv/country_date_format.csv
and /country_date_format.csv
with no avail.
I also tried to get my file as a resource but without success too as such
String path = DateFormatUtils.class.getClass().getResource("csv/country_date_format.csv").getPath()
I don't understand why I still get the file not found exception. Anyone can enlighten me?
The csv and the rest of the code is bundled inside a JAR