How can an app use files inside the JAR for read and write?

前端 未结 5 845
别那么骄傲
别那么骄傲 2020-11-21 23:09

I need to store data into files inside .jar file and read it again.

I know that I can use Class.getResourceAsStream() method but it returns an Inp

5条回答
  •  深忆病人
    2020-11-22 00:10

    Class.getResource() returns a URL. Theoretically, you can use this URL to create your InputStream and OutputStream. But in most cases, the generated JAR is a read-only file (or archive). So your application might trip when trying to use it.

提交回复
热议问题