test

import java.net.URL; 

public class MainClass { 

        public static void main(String[] args) { 

                String host = "www.java2s.com"; 
                String file = "/index.html"; 

                String[] schemes = {"http", "https", "ftp", "mailto", "telnet", "file", "ldap", "gopher", 
                                "jdbc", "rmi", "jndi", "jar", "doc", "netdoc", "nfs", "verbatim", "finger", "daytime", 
                                "systemresource"}; 

                for (int i = 0; i < schemes.length; i++) { 
                        try { 
                                URL u = new URL=\'#\'" host, file); 
                                System.out.println(schemes[i] + " is supported\r\n"); 
                        } catch (Exception ex) { 
                                System.out.println(schemes[i] + " is not supported\r\n"); 
                        } 
                } 
        } 
}

  

import java.net.URL; 

public class MainClass { 

        public static void main(String[] args) { 

                String host = "www.java2s.com"; 
                String file = "/index.html"; 

                String[] schemes = {"http", "https", "ftp", "mailto", "telnet", "file", "ldap", "gopher", 
                                "jdbc", "rmi", "jndi", "jar", "doc", "netdoc", "nfs", "verbatim", "finger", "daytime", 
                                "systemresource"}; 

                for (int i = 0; i < schemes.length; i++) { 
                        try { 
                                URL u = new URL=\'#\'" host, file); 
                                System.out.println(schemes[i] + " is supported\r\n"); 
                        } catch (Exception ex) { 
                                System.out.println(schemes[i] + " is not supported\r\n"); 
                        } 
                } 
        } 
}
posted @ 2012-11-27 10:31  jasonzhou  阅读(146)  评论(0编辑  收藏  举报