如何写入jar文件中的XML文件? [英] How to write to an XML file inside a jar file?

查看:197
本文介绍了如何写入jar文件中的XML文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨Java程序员。我非常需要你的帮助。

Hi Java programmers. I badly need your help.

我有一个JavaFX / Java ME应用程序。我正在尝试修改项目文件夹中的XML文件(很快就会打包jar文件)

I have a JavaFX/Java ME application. I'm trying to modify an XML file inside my project's folder (soon to be packaged jar file).

我想写的文件的路径:/parseExample/service1.xml

The path of the file I want to write: /parseExample/service1.xml

可悲的是,我的应用程序是JavaFx / JavaME,因此它不包含库 java.util.jar
所以我不能使用jar类。

Sadly, my application is a JavaFx/JavaME so it doesn't contain the library java.util.jar. So I can't use the jar classes.

还有其他方法吗?

推荐答案

即使在J2SE中,您也应该将Jar文件视为只读。在J2SE中,唯一的方法是使用外部工具或重新创建一个新的Jar文件,并用新文件覆盖旧文件。

Even in J2SE you should consider a Jar file as read only. In J2SE the only way to do it is either using external tools or recreating a new Jar file and overwriting the old one with the new.

我的建议是找到一个存储位置如下所示,如果您需要更改刚将新文件放在存储位置,请使用您的XML文件作为默认值。

My recommendation would be to find a storage location as listed below and use your XML file as a default, if you need to change the just put the new one in the storage location.

您的数据存储选项是以下内容:

Your data storage options are the following:

根据 http://developer.android.com/guide/topics/data/data-storage.html 以下是您可以使用的存储位置:

共享首选项 - 存储键值对中的私有原始数据。

内部存储 - 将私有数据存储在设备内存中。

外部存储 - 将公共数据存储在共享外部存储上。

SQLite数据库 - 将结构化数据存储在私有数据库中。

网络连接 - 将数据存储在Web上你自己的网络服务器。

As per http://developer.android.com/guide/topics/data/data-storage.html These are the possible storage locations you have available:
Shared Preferences - Store private primitive data in key-value pairs.
Internal Storage - Store private data on the device memory.
External Storage - Store public data on the shared external storage.
SQLite Databases - Store structured data in a private database.
Network Connection - Store data on the web with your own network server.

这篇关于如何写入jar文件中的XML文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆