Programmatically loading CSV files using Java

Scenario. The website that I use to study stock data has a link on the Export Data to Spreadsheet page. The URL displayed when you hover over the export link has the form http://www.stocksite.com/historical/export.php?symbol=C .

Question: Rather, to manually visit the page for each stock, I would like to automate the task. From Java, how can I programmatically call a site with a stock symbol and save the exported CSV file? The URL class and URLConnection seem like an obvious place to start, but I'm not sure where to go from there.

+3
source share
1 answer

, , CSV InputStream.

InputStream input = new URL("http://example.com/file.csv").openStream();

Java CSV parser API. InputStream Reader. InputStream Reader InputStreamReader, CSV.

Reader reader = new InputStreamReader(input, "UTF-8");
+12

Source: https://habr.com/ru/post/1773559/


All Articles