Created
March 20, 2012 03:34
-
-
Save gakuzzzz/2130894 to your computer and use it in GitHub Desktop.
fuyutsuto2
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
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.net.HttpURLConnection; | |
import java.net.URL; | |
import java.net.URLConnection; | |
public class PublicTimeLineViewer2 { | |
public static void main(String[] args) throws IOException { | |
URL url = new URL("http://api.twitter.com"); | |
HttpURLConnection URLConnect = (HttpURLConnection) url.openConnection(); | |
// try ( | |
// InputStream in = URLConnect.getInputStream(); | |
// InputStreamReader inputStreamReader = new InputStreamReader(in, "UTF-8"); | |
// BufferedReader br = new BufferedReader(inputStreamReader) | |
// ) { | |
// String line; | |
// while ((line = br.readLine()) != null) { | |
// System.out.println(line); | |
// } | |
// | |
// } | |
InputStream in = URLConnect.getInputStream(); | |
try { | |
InputStreamReader inputStreamReader = new InputStreamReader(in, "UTF-8"); | |
try { | |
BufferedReader br = new BufferedReader(inputStreamReader); | |
try { | |
String line; | |
while ((line = br.readLine()) != null) { | |
System.out.println(line); | |
} | |
} finally { | |
br.close(); | |
} | |
} finally { | |
inputStreamReader.close(); | |
} | |
} finally { | |
in.close(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment