java - Any way to get a File object from a JAR -


I have a JAR file that has an API using external model files I would like to include model files in jars So it is easy for other developers to use it. The API will accept only one file object, is there any way to do this? I have already tried, and they have failed:

  • Using class.getResourceAsStream (). This will work when the API accepts an input stream

    Parsing the classpath and trying to make it with entries (Jar will be shown as an app)

I think an option GetResourceAsStream is to use and files have to be taken to a permanent place on HDD but, I do not like this option. I think something better, any thoughts?

The resources in a .jar file are not in the sense that OS normally access them directly File Access API can

And since java.io.file actually displays that type of file (i.e. that looks like a file in the OS), it can not be a. The jar file is used to refer to anything.

A potential solution is to remove the resource in a temporary file and its reference is file . P> Note that usually the APIs that try to handle files should be written to handle InputStream / OutputStream and Also allow to carry out such operations.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -