// import java.net.*; import java.io.*; class URLTest { public static void main(String args[]) { try { URL home = new URL("http://orange.hnc.net:80/~yoonforh/applets/index.html#dir"); // URL »ý¼º DataInputStream dis; String line; System.out.println("Port # : "+String.valueOf(home.getPort())); System.out.println("Protocol : "+home.getProtocol()); System.out.println("Host : "+home.getHost()); System.out.println("File : "+home.getFile()); System.out.println("Ref : "+home.getRef()); // ÁöÁ¤µÈ URL·ÎºÎÅÍ ÀÔ·Â ½ºÆ®¸²À» ¿¬´Ù. dis = new DataInputStream(home.openStream()); while ((line = dis.readLine()) != null) { // ÀÔ·ÂÀÌ nullÀÏ ¶§±îÁö °è¼ÓÇؼ­ Àо Ç¥ÁØ Ãâ·ÂÀ¸·Î Ãâ·ÂÇÑ´Ù. System.out.println(line); } dis.close(); // ÀÔ·Â ½ºÆ®¸²À» ´Ý´Â´Ù. } catch (MalformedURLException e) { System.out.println("MalformedURLException: " + e); } catch (IOException e) { System.out.println("IOException: " + e); } } }