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

前端 未结 5 760
别那么骄傲
别那么骄傲 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-21 23:50

    You can manipulate any jar file using the package java.util.jar (or indeed just java.util.zip). As files inside a jar will be compressed, this isn't the most time efficient way for you to store data.

    You should probably use a directory somewhere else (e.g. System.getProperty("user.home") + "/.myProgram") or see java.util.prefs.

提交回复
热议问题