You are on page 1of 1

try {

String url = "http://finance.google.com/finance?q=" + nome +


"&output=json";
URL uri = new URL(this.url);
InputStream is = uri.openStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String jsonText = readAll(rd);
int ini = jsonText.indexOf("{");
int fin = jsonText.lastIndexOf("}") + 1;
String jsonFile = jsonText.substring(ini, fin);
JSONObject root = new JSONObject(jsonFile);
double value = root.getDouble("l");
} catch (MalformedURLException ex) {
Logger.getLogger(BolsaAPI.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(BolsaAPI.class.getName()).log(Level.SEVERE, null, ex);
}

You might also like