1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| public static String fich = null;
public static void main(String[] args) throws IOException {
String urlTemp = "http://finance.yahoo.com/d/quotes.csv?s=600000.Ss+600004.Ss&f=snd1l1yr";
File saveFile = new File("test.csv");
URL url = new URL(urlTemp);
URLConnection connection = url.openConnection();
InputStream is = connection.getInputStream();
FileOutputStream fos = new FileOutputStream(saveFile);
byte[] buffer = new byte[1024];
int read = 0;
while ((read = is.read(buffer, 0, buffer.length)) >= 0) {
fos.write(buffer, 0, read);
}
fos.flush();
fos.close();
is.close(); |
Partager