Question

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?

Was it helpful?

Solution

The Jar file is read-only on the device. Your midlet can read the text file, but can not write something back. (This is by design, the jar files may get preinstalled into ROM, or they may be signed. Or the device may do dome optimisations when your midlet is installed.)

You can write information into a thing called RecordStore. If you just need a flag, you write this flag into a RecordStore. The next time your midlet starts, you check if the recordstore exists and contains your flag.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top