1 7 package com.genimen.djeneric.test; 8 9 import java.net.URL ; 10 11 14 public class Util 15 { 16 public static String resource2FileName(URL baseUrl) throws Exception 17 { 18 return resource2FileName(baseUrl, null); 19 } 20 21 public static String resource2FileName(URL baseUrl, String fileName) throws Exception 22 { 23 if (baseUrl == null) 24 { 25 throw new Exception ("Could not locate database directory"); 26 } 27 28 String res = baseUrl.toString(); 29 if (fileName != null) res += "/" + fileName; 30 31 if (!res.startsWith("file:/")) 32 { 33 throw new Exception ("Sorry, only file based resources implemented; please unzip the zip/jar"); 34 } 35 36 return res.substring(6); 37 38 } 39 } | Popular Tags |