import java.io.InputStream;
import java.util.jar.JarFile;
import java.util.jar.JarEntry;
import java.net.URLDecoder;
public class Utils
{
public static InputStream readConfigFile()
{
return readJarFile("DemoData.properties");
}
public static InputStream readConfigFile(String fileName)
{
return readJarFile(fileName);
}
public static InputStream readJarFile(String packAndFileName)
{
String currentJarPath;
try {
currentJarPath = URLDecoder.decode(Utils.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();
}
}
}