展开全部
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(schemes[i], host, file);
System.out.println(schemes[i] + " is supported\r\n");
} catch (Exception ex) {
System.out.println(schemes[i] + " is not supported\r\n");
}
}
}
}
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(schemes[i], host, file);
System.out.println(schemes[i] + " is supported\r\n");
} catch (Exception ex) {
System.out.println(schemes[i] + " is not supported\r\n");
}
}
}
}
追问
前提是未知的url,我能取到这个url的开头,但是不知道怎么判断这个url是否已经结束
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询