I want load data from a CSV file into my program on startup. On my local machine it works just fine, but when I try to Dockerize the spring boot application, my CSV file cannot be found.
private final static String GIFTS_CSV = "gifts.csv";
public final static String PATH = "src/main/resources/static/";
public static Map<Integer, Gift> getGifts() throws IOException {
String line;
HashMap<Integer, Gift> gifts = new HashMap<>();
BufferedReader br = new BufferedReader(new FileReader(PATH + GIFTS_CSV));
br.readLine();
while ((line = br.readLine()) != null) {
String[] giftStr = line.split(CVS_SPLIT_BY);
Gift gift = new Gift(Integer.parseInt(giftStr[0]),
new Point(Double.parseDouble(giftStr[1]),
Double.parseDouble(giftStr[2])), Double.parseDouble(giftStr[3]));
gifts.put(gift.getId(), gift);
}
return gifts;
}
Is there a way to get this data in both environments? Or what would be the path on the docker image?