0

I have planned to develop a JME midlet. I want to include a text file in the Java ARchive. Each line in the text file will contain comma-separated strings. The last string in a line will be a flag.

I want my midlet to read the text file. I have looked at the MIDP 2.0 javadoc. The Class.getResourceAsStream(String name) method returns an InputStream objet. I can use this method to read my text file.

I want my midlet to change the flag of lines in my text file. Is it possible to write in the text file included in my JAR? If so then what classes and methods I have to use?

4

1 回答 1

2

Jar 文件在设备上是只读的。您的 midlet 可以读取文本文件,但不能写回某些内容。(这是设计使然,jar 文件可能会预先安装到 ROM 中,或者可能会被签名。或者设备可能会在安装 midlet 时进行圆顶优化。)

您可以将信息写入一个名为 RecordStore 的东西中。如果您只需要一个标志,则将此标志写入 RecordStore。下次您的 midlet 启动时,您检查记录存储是否存在并包含您的标志。

于 2013-03-09T23:43:01.510 回答