I want to use relative path in my code but relative is not working for me but working on absolute path. here my code(Utils.java
package org.example;
import org.example.model.Stats;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
public class Utils {
private static final String FILE_PATH = "/home/project/Dummy/src/main/resources/data.csv";
public static List<Stats> readData() {
List<Stats> StatsList = new ArrayList<>();
try (BufferedReader br = new BufferedReader(
new FileReader(FILE_PATH))
) {
String line;
while ((line = br.readLine()) != null) {
String[] fields = line.split(",");
Stats Stats = new Stats();
Stats.setName(fields[0]);
Stats.setAddress(fields[1]);
Stats.setContact(fields[2]);
Stats.setAbout(fields[3]);
StatsList.add(Stats);
}
} catch (IOException e) {
System.out.println("Error opening file: " + e.getMessage());
}
return StatsList;
}
In below i give the image of my project structure