how to write into a text file in Java

前端 未结 5 1451
南旧
南旧 2021-01-27 01:35

I am doing a project in java and in that i need to add and modify my text file at runtime,which is grouped in the jar.

I am using class.getResourceAsStream(filename) thi

5条回答
  •  醉酒成梦
    2021-01-27 02:16

    All JAR rewriting techniques in Java look similar. Open the Jar file, read all of it's contents, and write a new Jar file containing the unmodified contents (and the modifications you whished to make). Such techniques are not advisable for a Jar file on the class path, much less a Jar file you're running from.

    If you decide you must do it this way, Java World has a few articles:

    Modifying Archives, Part 1

    Modifying Archives, Part 2

提交回复
热议问题