1 5 package com.tc.net.util; 6 7 import java.io.IOException ; 8 import java.io.InputStream ; 9 import java.net.MalformedURLException ; 10 import java.net.URL ; 11 12 public final class URLUtil { 13 14 private URLUtil() { 15 throw new RuntimeException ("Don't try to instantiate this [utility] class"); 16 } 17 18 23 public static URL resolve(final URL [] baseURLs, final String path) throws MalformedURLException { 24 if (baseURLs != null && path != null) { 25 for (int pos = 0; pos < baseURLs.length; pos++) { 26 final URL testURL = new URL (baseURLs[pos].toString() + (baseURLs[pos].toString().endsWith("/") ? "" : "/") 27 + path); 28 try { 29 final InputStream is = testURL.openStream(); 30 is.read(); 31 is.close(); 32 return testURL; 33 } catch (IOException ioe) { 34 } 36 } 37 } 38 return null; 39 } 40 41 } 42 | Popular Tags |