|
package com.apc.config;
import java.io.InputStream; import java.net.URLDecoder; import java.util.jar.JarEntry; import java.util.jar.JarFile; public class ReadJar { public static InputStream readConfigFile() { return readJarFile("com/apc/config/config.xml"); } public static InputStream readJarFile(String packAndFileName) { String currentJarPath; try { currentJarPath = URLDecoder.decode(ReadJar.class.getProtectionDomain().getCodeSource().getLocation().getFile(), "UTF-8 "); JarFile currentJar = new JarFile(currentJarPath); JarEntry dbEntry = currentJar.getJarEntry(packAndFileName); return currentJar.getInputStream(dbEntry); } catch (Exception e) { return null; //e.printStackTrace(); } } }
|
一共有 0 条评论