I have a web URL which returns a JSON formatted string on request
{"StockID":0,"LastTradePriceOnly":"494.92","ChangePercent":"0.48"}
I'm streaming this using Java
InputStream in = null;
in = url.openStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
}
catch (IOException e) {
e.printStackTrace();
} finally {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
String result = sb.toString();
But reader.readLine()
is always returning null
Any idea what I'm doing wrong here?
Here is the actual JSON address http://app.myallies.com/api/quote/goog
UPDATE
Same code works OK on http://app.myallies.com/api/news, although both links have the same server implementation to generate the JSON response.