class PkgConst { static final String CRT_TYPE = "X.509"; static final String CRT_FILE = java.lang.ClassLoader.getSystemResource("com/demoapp/demo/https/httpsfile/https.crt") .getFile(); static final String KEYSTORE_TYPE = "JKS"; static final String KEYSTORE_FILE = java.lang.ClassLoader.getSystemResource("com/demoapp/demo/https/httpsfile/https.keystore") .getFile(); static final String KEYSTORE_PASSWORD = "******"; static final String KEYSTORE_ALIAS = "yongnian.jiang"; }
/** * Returns the URL of the resource specified by {@code resName}. The mapping between the resource * name and the URL is managed by the class' class loader. * * @param resName the name of the resource. * @return the requested resource's {@code URL} object or {@code null} if the resource can not be * found. * @see ClassLoader */ public URL getResource(String resName) { // Get absolute resource name, but without the leading slash if (resName.startsWith("/")) { resName = resName.substring(1); } else { String pkg = getName(); int dot = pkg.lastIndexOf('.'); if (dot != -1) { pkg = pkg.substring(0, dot).replace('.', '/'); } else { pkg = ""; } resName = pkg + "/" + resName; } // Delegate to proper class loader ClassLoader loader = getClassLoader(); if (loader != null) { return loader.getResource(resName); } else { return ClassLoader.getSystemResource(resName); } }
public URL getResource(String resName) { ClassLoader loader = type.getClassLoader(); if (loader == BootstrapClassLoader.getBootstrapClassLoader()) return ClassLoader.getSystemResource(toResourceName(resName)); else return loader.getResource(toResourceName(resName)); }