Created
June 29, 2013 13:53
-
-
Save pbrewczynski/5891183 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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