mercredi 31 mai 2017

Java read CSV file from the web

I'm trying to read a CSV file from the web. Here's the Java code I have written:

String st = "http://ift.tt/2qBCVG7";
URL stockURL = new URL(st);
BufferedReader in = new BufferedReader(new InputStreamReader(stockURL.openStream()));
String s = null;
while ((s=in.readLine())!=null) {
    System.out.println(s);
}

However, the BufferedReader appears to be empty. When I put the URL in my browser, a CSV file is downloaded which is not an empty file. Any ideas? enter image description here




Aucun commentaire:

Enregistrer un commentaire