Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2011
    Posts
    1
    Rep Power
    0

    Smile Stock Feeds Code

    I would like to get free stock feeds from yahoo or google.
    Java code.
    anyone has an idea?
    TY

  2. #2
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default Re: Stock Feeds Code

    If you can get an XML feed that should be pretty simple.
    Java Code:
    public String getXMLString(String xmlFileURL) {
        String output = " ";
        InputStream in = null;
        BufferedReader reader = null;
        try {
            in = new URL.openStream(xmlFileURL);
            reader = new BufferedReader(new InputStreamReader(in));
            String read;
            while ((read = reader.readLine())!=null) {
                output += read;
            }
            in.close();
            reader.close();
        } catch (MalformedURLException e) {
        } catch (FileNotFoundException e) {
        } catch (IOException e) {
        }
        return output;
    }
    From there all you have to do is parse the XML String into a Document using DocumentBuilderFactory and then loop through the nodes.
    (See docs for: org.w3c.dom.Document, org.w3c.dom.Element, org.w3c.dom.Node, org.w3c.dom.NodeList)

Similar Threads

  1. The Stock Class
    By luckyirish in forum New To Java
    Replies: 9
    Last Post: 07-13-2011, 04:40 AM
  2. live market feeds...desperation!
    By shy_ted in forum New To Java
    Replies: 9
    Last Post: 09-19-2010, 08:09 PM
  3. Implementing Rss Feeds
    By madhu_sushmi in forum Advanced Java
    Replies: 0
    Last Post: 04-02-2010, 02:14 AM
  4. Stock Quotes
    By BartDR in forum Advanced Java
    Replies: 0
    Last Post: 09-15-2009, 09:15 AM
  5. Help with reading RSS feeds
    By Albert in forum XML
    Replies: 1
    Last Post: 07-13-2007, 03:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •