Open and edit a file in .jar using Java?

How would you start to open the XML file that is inside the .jar and edit it?

I know you can ...

InputStream myStream = this.getClass().getResourceAsStream("xmlData.xml");

But how would you open xmlData.xml, edit the file and save it in .jar? I would find it useful to know and don’t want to edit the file outside of .jar ... and the application should remain functional all the time!

Thank!

+5
source share
2 answers

Jar files are just .zip files with different file suffixes and a naming convention for content. Therefore, use classes from java.util.zipto read and / or write content.

( ) , .

, . ...

+3

. , -/, JWS . API JNLP, JWS. , PersistenceService. . PersistenceService.

, XML JWS. , , . , .

. . , , ..

+1

All Articles