ch1_example17_getHTTPHeaders.txt
2 import java.net.URLConnection;
3 import java.io.*;
4 import java.util.*;
5
6 public class HTTPGET{
7 public static void main (String [] Args){
8 try{
9 FileWriter file = new FileWriter( "OutFile" );
10 PrintWriter OutputFile = new PrintWriter( file );
11
12 URL url = new URL( "http://www.google.com" );
13 URLConnection urlConnection = url.openConnection();
14 InputStream IS = urlConnection.getInputStream();
15
16 IS.close();
17 OutputFile.print( IS );
18 } catch (Exception e) { System.out.println("Error"); }
19 }
20 }