Skip to content

Instantly share code, notes, and snippets.

@springcome
Created October 17, 2013 01:52
Show Gist options
  • Save springcome/7018069 to your computer and use it in GitHub Desktop.
Save springcome/7018069 to your computer and use it in GitHub Desktop.
URLConnection
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
public class URLConnectionExam {
public static void main(String[] args) {
String inputLine = "";
try {
URL url = new URL("http://www.springcome.me/?p=69");
URLConnection connect = url.openConnection();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connect.getInputStream()));
while (null != (inputLine = bufferedReader.readLine())) {
System.out.println(inputLine);
}
bufferedReader.close();
} catch (Exception e) {
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment