[MENTION=42437]over[/MENTION]ride
public void onClick(View v) {
// TODO Auto-generated method stub
URL url;
String molina="moli.ba";
String moli = ("http://download.finance.yahoo.com/d/quotes.csv?s="+molina+"&f=l1p2");
try {
url= new URL(moli);
InputStream stream= url.openStream();
BufferedInputStream bis = new BufferedInputStream(stream);
ByteArrayBuffer baf = new ByteArrayBuffer(50);
int current=0;
while((current = bis.read()) != -1) {
baf.append((byte) current);
}
String stockTxt = new String(baf.toByteArray());
String[] tokens = stockTxt.split(",");
String stockSymbol = tokens[0];
String stockPrice = tokens[1];
String stockChangePercentage = tokens [2];
String fstockSymbol = stockSymbol.substring(1, stockSymbol.length()-1);
String fstockChangePercentage = stockChangePercentage.substring(1,
stockChangePercentage.length()-3);
symbolOut.setText(fstockSymbol);
priceOut.setText(stockPrice);
ChangePercentageOut.setText(fstockChangePercentage);
}catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}