1 package it.stefanochizzolini.reflex; 2 3 import java.io.File ; 4 import java.net.URI ; 5 import java.net.URL ; 6 7 public class Class 8 { 9 15 public static String getLocation( 16 String className 17 ) 18 { 19 String classResourcePath = className.replace('.', '/') + ".class"; 20 URL classUrl = Thread.currentThread().getContextClassLoader().getResource(classResourcePath); 22 if(classUrl == null) 23 return null; 24 25 String location; 27 try 28 { 29 location = new File (classUrl.getFile()).getPath(); 30 } 31 catch(Exception e) 32 {throw new RuntimeException (e);} 33 int index = location.indexOf("!"); 35 if(index >= 0) 36 { 37 location = location.substring(0, index); 39 } 40 index = location.indexOf(":"); 42 if(index >= 0) 43 { 44 location = location.substring(++index); 46 } 47 48 return location; 49 } 50 } | Popular Tags |