简体   繁体   中英

java.util.zip.ZipException: error in opening zip file while having whitespace in url path

I have a URL, which contains a white-space in middle, When I invoke the new JarFile() constructor on this file, I am getting an exception "java.util.zip.ZipException: error in opening zip file"

I am trying the following url

URL url = file:/usr/local/mvn%20repo/javax/persistence/persistence-api/2.0/persistence-api-2.0.jar

and creating JarFile object

JarFile jarFile = new JarFile(url.getFile());

and getting error following error:

java.util.zip.ZipException: error in opening zip file

Thanks KK

Try file:// as the protocol. So in total it would contain 3 slashes and look like this:

file:///usr/local/mvn%20repo/javax/persistence/persistence-api/2.0/persistence-api-2.0.jar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM