How to extract a single file from a remote archive file?

前端 未结 4 1368
广开言路
广开言路 2020-12-05 20:29

Given

  1. URL of an archive (e.g. a zip file)
  2. Full name (including path) of a file inside that archive

I\'m looking for a way (preferably i

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-05 20:50

    Since TrueZIP 7.2, there is a new client API in the module TrueZIP Path. This is an implementation of an NIO.2 FileSystemProvider for JSE 7. Using this API, you can access HTTP URI as follows:

    Path path = new TPath(new URI("http://acme.com/download/everything.tar.gz/README.TXT"));
    try (InputStream in = Files.newInputStream(path)) {
        // Read archive entry contents here.
        ...
    }
    

提交回复
热议问题