The format of the
jar: URI scheme is simply defined to be
Is it possible to “nest” two such URIs together and refer to a file inside an archive inside an archive this way? Something like:
This should designate
/file inside an archive
jar:http://example.com/!/archive, that is
/archive found in a file provided by
URL.openConnection throws an exception:
java.net.MalformedURLException: no !/ in spec
I also cannot replace
%21 since that makes the
jar: URI invalid, and I am not aware of any escaping that could be performed. Is this somehow possible? Or, as a more generic question, is it possible to store a URI with
<url> so that it is preserved?
As it is stated in the source code
java.net.JarURLConnection does not handle nested Jar URIs.
jar:jar:http://example.com/!/archive!/fileis parsed as entry
archive!/file in the archive
jar:http://example.com/. The latter is not a valid jar URI. You can not either escape the
!/ sequences, because the text after
jar: and before
!/ must be a valid URI without any translation.
You can of course provide your own
URLConnection implementation that supports nested Jar URIs.