Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8289949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:39:02+00:00 2026-06-08T12:39:02+00:00

I need to find a solution to be able to manipulate a zip /

  • 0

I need to find a solution to be able to manipulate a zip / jar directly (without unpacking) and without using third-party libraries. However I can’t seem to grasp how the FileSystem ties in with Path and URI.

The URI that I’m trying to copy to is
jar:file://E:/Projects/ZipDir/dist/test_folder/test.zip!/test_file.txt

The exception I’m getting is:
FileSystemNotFoundException but that zip file definitely does exist.

Using Java 7, this is what I have so far:

...
ZipDirectory zip = new ZipDirectory("test_folder/test.zip");
Path copyTo = zip.getPath("/test_file.txt");
Path copyFrom = Paths.get("test_file.txt");

Files.copy(copyFrom, copyTo, StandardCopyOption.REPLACE_EXISTING);
...

//

import java.io.IOException;
import java.net.URI;
import java.nio.file.*;
import java.util.HashMap;

public class ZipDirectory {

    private Path path;
    private FileSystem fileSystem;

    public ZipDirectory(String path){
        this.path = Paths.get(Paths.get(path).toUri());
        create();
    }

    private void create(){
        HashMap<String, String> env = new HashMap<>(); 
        env.put("create", "true");
        try {          
            fileSystem = FileSystems.newFileSystem(path, null);
        } catch (IOException ex) {
            System.out.println(ex);
        }
    }

    public Path getPath(String relativePath){
        return Paths.get(URI.create("jar:file:/" + path.toUri().getPath() + "!" + fileSystem.getPath(relativePath)));
    }

    public Path getRoot(){
        return Paths.get(URI.create(path.toUri().getPath() + "!/"));
    }

    public void close(){
        try {
            fileSystem.close();
        } catch (IOException ex) {
            System.err.println(ex);
        }
        fileSystem = null;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:39:04+00:00Added an answer on June 8, 2026 at 12:39 pm

    I never thought I’d answer my own question, but I’ve got it working:

    Treating an archive like a directory with Java 7

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Searched all over, but haven't been able to find a solution. I need to
I need to find a flexible solution for access control in PHP. In the
I already googled around to find a solution for my need, with no success.
i have a big solution containing that much projects..i need to find a specific
I've been searching the net but couldn't find a solution for this. I need
Simple question: I need a solution so that I can find, lets say names,
I need to store the application settings somewhere, but can't find a satisfying solution.
I have a problem that I haven't been able to find a solution to,
I need to be able to complete a vbscript msgbox using javascript. The problem
I'm surprised I haven’t been able to find the solution floating around online. There

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.