public static void copy(URL url,File file) throws IOException {
  InputStream is=url.openStream();
  try {
    OutputStream os=new FileOutputStream(file);
    try {
      byte[] buffer=new byte[8192];
      int read;
      while ((read=is.read(buffer)) > 0) {
        os.write(buffer,0,read);
      }
    }
  finally {
      os.close();
    }
  }
  finally {
    is.close();
  }
}

public static void copy ( URL url , File file ) throws IOException { InputStream is = url . openStream ( ) ; try { OutputStream os = new FileOutputStream ( file ) ; try { byte [ ] buffer = new byte [ 8192 ] ; int read ; while ( ( read = is . read ( buffer ) ) > 0 ) { os . write ( buffer , 0 , read ) ; } } finally { os . close ( ) ; } } finally { is . close ( ) ; } }
copy a url to a file .
