java.util.zip.ZipException: Could not find End Of Central Directory
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:117)
at java.util.jar.JarFile.(JarFile.java:133)
at java.util.jar.JarFile.(JarFile.java:97)
at Test.main(Test.java:50)
public static String getJarFilePath(String path){
if(path.indexOf("!")!=-1)
path=path.substring(0,path.indexOf("!"));
if(path.indexOf("file:/")!=-1)
path=path.substring(path.indexOf("file:/")+"file:/".length());
return path;
}
public static void main(String[] args) {
String configFilePath="";
URL confifUrl=Test.class.getClassLoader().getResource("config.properties");
configFilePath=confifUrl.getPath();
System.out.println(configFilePath);
try {
JarFile jarFile=new JarFile(new File(getJarFilePath(configFilePath)));
System.out.println("jarFile:"+jarFile);
} catch (IOException e) {
e.printStackTrace();
}
}