Abstraction layer over the file system and jar/zip

2019-06-26 07:05发布

Is there a Java library, which provides an abstraction layer over the file system and jar/zip. I checked apache common vfs but it does not support such operations as listing directory content and file rename for Jar/Zip.

Suppose there is some code, which uses java.io.File and its friends to access files in the file system, and I need to make it work if these files are in Jar/Zip. I would like to find an API, which is very similar to java.io.File, to make the code refactoring easier.

标签: java file jar
2条回答
男人必须洒脱
2楼-- · 2019-06-26 07:50

I haven't used it yet, but are you looking for the Zip File System Provider introduced in Java 7?

查看更多
闹够了就滚
3楼-- · 2019-06-26 08:06

Zip File System Provider doesn't work as the abstraction layer exactly because of java.io.File:

public class ZipPath implements Path {

@Override
public final File toFile() {
    throw new UnsupportedOperationException();
    }
}

The closest API I could find is TrueZIP/TrueVFS by Christian Schlichtherle https://truevfs.java.net/ but it has its own issues.

查看更多
登录 后发表回答