Skip to content

Instantly share code, notes, and snippets.

@gakuzzzz
Created March 20, 2012 03:34
Show Gist options
  • Save gakuzzzz/2130894 to your computer and use it in GitHub Desktop.
Save gakuzzzz/2130894 to your computer and use it in GitHub Desktop.
fuyutsuto2
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