1 21 24 package org.lobobrowser.util; 25 26 import java.net.*; 27 28 public class Urls { 29 32 private Urls() { 33 super(); 34 } 35 36 public static boolean isRemote(java.net.URL url) { 37 String scheme = url.getProtocol(); 38 return "http".equalsIgnoreCase(scheme) || 39 "https".equalsIgnoreCase(scheme) || 40 "ftp".equalsIgnoreCase(scheme) || 41 ("file".equalsIgnoreCase(scheme) && hasHost(url)); 42 } 43 44 public static boolean isLocalFile(java.net.URL url) { 45 String scheme = url.getProtocol(); 46 return "file".equalsIgnoreCase(scheme) && !hasHost(url); 47 } 48 49 public static boolean hasHost(java.net.URL url) { 50 String host = url.getHost(); 51 return host != null && !"".equals(host); 52 } 53 54 58 public static URL createURL(URL baseUrl, String relativeUrl) throws java.net.MalformedURLException { 59 return new URL(baseUrl, relativeUrl); 60 } 61 } 62 | Popular Tags |