Get a File or URI object for a file inside an archive with Java?

前端 未结 3 1656
失恋的感觉
失恋的感觉 2020-12-31 10:56

is it possible to get a File or URI object for a file inside an archive with Java? (zip or jar archive)

Thanks Hemeroc.

3条回答
  •  执笔经年
    2020-12-31 11:28

    The jar: protocol is a way to build a URI to a resource in a JAR archive:

    jar:http://www.example.com/bar/baz.jar!/path/to/file
    

    See the API docs for JarURLConnection: http://java.sun.com/javase/6/docs/api/java/net/JarURLConnection.html

    Between the jar: and !/ can be any URL, including a file: URL.

提交回复
热议问题