List of utility methods to do ClassLoader Load
List | getFullPathByPkg(String pkg) get Full Path By Pkg List<String> result = new ArrayList<>(); ClassLoader loader = Thread.currentThread().getContextClassLoader(); String packagePath = pkg.replace(".", "/"); URL url = loader.getResource(packagePath); File dir = new File(url.getPath()); StringBuilder str = new StringBuilder(); for (File f : dir.listFiles()) { str.append(pkg).append("."); ... |
String | getImageFilename(String name) Adds the path of the images directory to the name of the image. String result; String dir; URL url; result = null; dir = "com/github/fracpete/screencast4j/images/"; try { url = ClassLoader.getSystemClassLoader().getResource(dir + name); if (url != null) ... |
InputStream | getInputStream(String name) get Input Stream ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); InputStream is = null; if ((name != null) && (name.indexOf(":/") > -1)) { try { is = new URL(name).openStream(); } catch (Exception e) { URL url = classLoader.getResource(name); if (is == null) { try { is = classLoader.getResourceAsStream(name); } catch (Exception e) { if (is == null) { try { is = classLoader.getResourceAsStream('/' + name); } catch (Exception e) { if (is == null) { try { is = classLoader.getResourceAsStream("META-INF/" + name); } catch (Exception e) { if (is == null) { try { is = new FileInputStream(name); } catch (FileNotFoundException e) { return is; |
String | getLibKoyaVersion() get Lib Koya Version Enumeration resEnum; try { resEnum = Thread.currentThread().getContextClassLoader().getResources("META-INF/build.properties"); while (resEnum.hasMoreElements()) { try { URL url = (URL) resEnum.nextElement(); InputStream is = url.openStream(); Properties prop = new Properties(); ... |
File | getLocalFile(final String aLocalPath) get Local File try { return new File(ClassLoader.getSystemResource("").toURI().getPath(), aLocalPath); } catch (final URISyntaxException uiUriSyntaxException) { throw new IllegalStateException("This is a critical error. Please report it.", uiUriSyntaxException); |
URL | getLog4jPropertiesLocation() get Logj Properties Location URL systemResource = ClassLoader.getSystemResource(LOG4J_PROPERTIES);
return systemResource;
|
String | getManifestInfo() get Manifest Info Enumeration resEnum; try { resEnum = Thread.currentThread().getContextClassLoader().getResources(JarFile.MANIFEST_NAME); while (resEnum.hasMoreElements()) { try { URL url = (URL) resEnum.nextElement(); InputStream is = url.openStream(); if (is != null) { ... |
String | getMetadataSpecialSymbolsXml() get Metadata Special Symbols Xml return new File(ClassLoader.getSystemClassLoader().getResource("dpp/metadata-special-symbols.xml").toURI()) .getAbsolutePath(); |
String | getPath(final String fileName) get Path final URL url = ClassLoader.getSystemResource(fileName); if (url != null) { return url.getFile(); } else { throw new IllegalArgumentException( "File " + fileName + " does not exist on the classpath: " + CLASSPATH); |
String | getPath(String resoureLocation) This function returns the absolute path of a class path resource. return getContextClassLoader().getResource(resoureLocation).toURI().getPath();
|