1 51 package org.apache.fop.tools; 52 53 import java.io.File ; 54 import java.net.URL ; 55 import java.net.MalformedURLException ; 56 57 64 public class URLBuilder { 65 66 74 public static URL buildURL(String spec) throws MalformedURLException { 75 if (spec == null) throw new NullPointerException ("spec must not be null"); 76 File f = new File (spec); 77 if (f.exists()) { 78 return f.toURL(); 79 } else { 80 URL u1 = new URL (spec); 81 return u1; 82 } 83 } 84 85 86 95 public static URL buildURL(URL baseURL, String spec) throws MalformedURLException { 96 if (spec == null) throw new NullPointerException ("spec must not be null"); 97 try { 98 URL u1 = buildURL(spec); 99 return u1; 100 } catch (MalformedURLException mfue) { 101 if (baseURL == null) throw mfue; 102 URL u2 = new URL (baseURL, spec); 103 return u2; 104 } 105 } 106 107 } | Popular Tags |