/** Kody zaczerpniete z polskiej edycji        *
 *  ksiazki Serwisy internetowe. Programowanie *
 *  Wydawnictwo Helion, Gliwice,               *
 *  ftp://ftp.helion.pl/przyklady/serinp.zip   *
 *  &copy; 2001 Marty Hall and Larry Brown;    *
 */
 
 // Dalsze uproszczenie metody dajURL. 
 
 public URL getURL() {
    if (url != null) {
      return(url);
    }
    System.out.print("Wprowad adres URL: ");
    System.out.flush();
    BufferedReader in = new BufferedReader(
                          new InputStreamReader(System.in));
    String urlString = null;
    try {
      urlString = in.readLine();
      url = new URL(urlString);
    } catch(MalformedURLException mue) {
      System.out.println("Adres " + urlString + " jest niepoprawny.\n" +
                         "Sprbuj ponownie.");
      dajURL();
    } catch(IOException ioe) {
      System.out.println("Bd IOError podczas wprowadzania danych: " + ioe);
      ioe.printStackTrace(); // W tej wersji mona pomin instrukcj return(null)
    } finally {
      return(url);
    }
  }