Download a whole website using URL class in Java
<p>I wrote a simple program which through the help of url class get the page content. However, it gets only the main page of the website, and inside a page there are also other urls. How can we download all the website including the page inside the specified url page.</p>

<pre><code>import java.net.*;
import java.io.*;
public class Map {
  public static void main(String args[]){
    System.setProperty("http.proxyHost","192.168.10.50");
    System.setProperty("http.proxyPort","8080");
       String nextLine;
       URL url = null;
       URLConnection urlConn = null;
       InputStreamReader  inStream = null;
       BufferedReader buff = null;
       try{
          // Create the UR0L obect that points
          // at the default file index.html
          url  = new URL("http://www.iiu.edu.pk/index.php?page_id=10135" );
         //URL url2=new URL(url,"index.php?page_id=10135");
          urlConn = url.openConnection();
         inStream = new InputStreamReader( 
                           urlConn.getInputStream());
           buff= new BufferedReader(inStream);
           FileWriter writer=new FileWriter(" check.html");
           BufferedWriter buf=new BufferedWriter(writer);


   // Read and print the lines from index.html
    while (true){
        nextLine =buff.readLine();  
        if (nextLine !=null){
            System.out.println(nextLine); 
            buf.write(nextLine);
            buf.newLine();
        }
        else{
           break;
        } 
    }
    buff.close();
    inStream.close();
    buf.close();
   writer.close();

 } catch(MalformedURLException e){
 System.out.println(e);

 } catch(IOException  e1){
     System.out.println(e1);

}
</code></pre>
