homeduke Prof. Dr. Uwe Schmidt FH Wedel

Die Datei: URLConstruction.java


weiter
   1import java.net.URL;
   2import java.net.MalformedURLException;
   3
   4public class URLConstruction {
   5
   6    public static void main(String [] argv) {
   7        try {
   8            URL [] u = {
   9                new URL("http://www.fh-wedel.de/~si/index.html"),
  10
  11                new URL("http",
  12                        "www.fh-wedel.de",
  13                        "/~si/index.html"),
  14
  15                new URL("http",
  16                        "www.fh-wedel.de",
  17                        80,
  18                        "/~si/index.html#start"),
  19                null,
  20
  21                new URL("file://localhost/etc/passwd"),
  22
  23                new URL("file",
  24                        "localhost",
  25                        "/etc/passwd")
  26            };
  27
  28            u[3] = new URL(u[0],
  29                           "document.html");
  30
  31
  32            for (int i = 0;
  33                     i < u.length;
  34                     ++i ) {
  35                System.out.println(u[i]           + "\n " +
  36                                   u[i].getProtocol() + "\n     " +
  37                                   u[i].getHost() + "\n " +
  38                                   u[i].getPort() + "\n " +
  39                                   u[i].getFile() + "\n " +
  40                                   u[i].getRef()  + "\n");
  41            }
  42        }
  43        catch (MalformedURLException e) {
  44            System.out.println(e);
  45        }
  46    }
  47}

Die Quelle: URLConstruction.java


Letzte Änderung: 10.12.1998
© Prof. Dr. Uwe Schmidt
Prof. Dr. Uwe Schmidt FH Wedel