Skip to content

Instantly share code, notes, and snippets.

@pbrewczynski
Created June 29, 2013 13:53
Show Gist options
  • Save pbrewczynski/5891178 to your computer and use it in GitHub Desktop.
Save pbrewczynski/5891178 to your computer and use it in GitHub Desktop.
try{
URL url = new URL("http://98.137.200.255/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22AAPL%22)&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys");
URLConnection connection;
connection = url.openConnection();
HttpURLConnection httpConnection = (HttpURLConnection) connection;
int responseCode = httpConnection.getResponseCode();
if(responseCode == HttpURLConnection.HTTP_OK) { // 200
System.out.println("------------TRUE----------");
InputStream in = httpConnection.getInputStream();
while (true) {
int tmpInt = in.read();
if(tmpInt != -1) {
System.out.print( (char) tmpInt );
} else {
System.out.print("END OF STREAM");
break;
}
}
System.out.println((char) in.read());
}
} catch (MalformedURLException e1) {
e1.printStackTrace();
} catch (IOException e2) {
e2.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment