I have a CSV file that I copy in my work package, I want read it from my package not a path on my PC in order to not change the link every time I change my PC but I do not know how do this, I tried a solution that did not work for me this is my code :
public static void main(String[] args) {
CSV obj = new CSV();
obj.run();
}
public void run() {
String csvFile = "C:/Users/Intervalle tech/Desktop/SV.csv";
BufferedReader br = null;
String line = "";
//URL url = Thread.currentThread().getContextClassLoader().getResource("/BocOperations/src/operations/SV.csv");
//File file = new File(url.getPath());
try {
br = new BufferedReader(new FileReader(csvFile));
while ((line = br.readLine()) != null) {
// use comma as separator
// String[] Element = line.split(cvsSplitBy);
System.out.println( line );
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}