1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; public class UserAgent { public static void main(String[] args) throws IOException { URL url = new URL("http://www.jesusninoc.com"); String inputLine; URLConnection hc = url.openConnection(); hc.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2)"); BufferedReader br = new BufferedReader(new InputStreamReader(hc.getInputStream())); while ((inputLine = br.readLine()) != null) { System.out.println(inputLine); } br.close(); } } |