开发者

Can you access items inside a jar using File

I have some files inside a jar which I would like to access in Java using a File object rather than as a stream.开发者_如何学Python Is it possible to do this?


Look at JarFile.


java.io.File is an abstraction from os specific handling of files. If you use java.io.File in your code, the code should run on all Java platforms.

The Jar is not a os file system. So it makes no sense to apply java.io.Files from the Java core classes.

I don't want to say it is not possible. Maybe it has sense for certain application and there is a library for that kind of abstraction.


You can also access it as a URL with a "jar:" prefix, but that's not a File object either, so I guess that doesn't meet the restriction.

Why do you have to access it as a File? This seems like asking, "Is there any way I can add two numbers without using the plus operator?" Maybe you can, but why do you not want to do it the easy way?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜