I have a problem reading a csv file from the web. I get a File not found exception. That's the source: http://data.okfn.org/data/core/s-and-p-500-companies/r/constituents.csv How could it be the file cannot be found if I can easily open it ? what am I missing here ?
package Investing;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class Main {
public static void main(String[] args) {
String csvFile = "http://data.okfn.org/data/core/s-and-p-500- companies/r/constituents.csv";
String line = "";
String cvsSplitBy = ",";
try (BufferedReader br = new BufferedReader(new FileReader(csvFile))) {
while ((line = br.readLine()) != null) {
// use comma as separator
String[] data = line.split(cvsSplitBy);
System.out.println(data);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}