KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > genimen > djeneric > test > Util


1 /*
2  * Created on 3-mrt-03
3  *
4  * To change this generated comment go to
5  * Window>Preferences>Java>Code Generation>Code Template
6  */

7 package com.genimen.djeneric.test;
8
9 import java.net.URL JavaDoc;
10
11 /**
12  * @author Wido Riezebos
13  */

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