Return to Snippet

Revision: 24421
at March 1, 2010 15:19 by sukantahazra


Initial Code
import java.net.*;
import java.io.*;


public class ForexTest {
    public void getRate() {
        try {
            URL url = new URL("http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=EURUSD=X");
            URLConnection urlc = url.openConnection();

            BufferedReader reader = new BufferedReader(new InputStreamReader(urlc.getInputStream()));

            String line;
            StringBuffer sb = new StringBuffer();

            while ((line = reader.readLine()) != null) {
                sb.append(line);
            }
            System.out.println(sb);


        } catch (MalformedURLException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    public static void main(String[] args) throws Exception {
        ForexTest ft = new ForexTest();
        while (true) {
            ft.getRate();
            Thread.sleep(10000);
        }

    }
}

Initial URL

                                

Initial Description

                                

Initial Title
Download forex quote for yahoo using java

Initial Tags
java, web

Initial Language
Java