Skip to content

Instantly share code, notes, and snippets.

@plentz
Created June 30, 2011 16:29
Show Gist options
  • Save plentz/1056596 to your computer and use it in GitHub Desktop.
Save plentz/1056596 to your computer and use it in GitHub Desktop.
import java.net.URL;
import java.net.URLConnection;
import java.util.Scanner;
public class HTTPSample {
public static void main(String[] args) throws Exception {
URLConnection con = new URL("https://encrypted.google.com/search?q=java").openConnection();
con.setRequestProperty("User-Agent", "oi");
Scanner sc = new Scanner(con.getInputStream());
System.out.println(sc.useDelimiter("\\Z").next().toString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment