| Reply | « Previous Thread | Next Thread » |
|
Hi!
I must read the user attributes from the manifest.mf file using Class.getResourceAsStream() -method. I am using my midlet as the class loader. The code that should read the file is: myMidlet.getClass().getResourceAsStream("/META-INF/MANIFEST.MF"); The problem is that the read manifest is not the one that is found on my package. Presumeably it reads the 1st occurrence that is found. So how can I read the correct manifest file? ps. I am not allowed to read the params from JAD-file. |
|
dont know how u have done it ....below is the code that reads the manifest file correctly
only u need to give path of ur manifest file: private void readTextFile() { ReaderClass rd = new ReaderClass(); try { Class c = rd.getClass(); InputStream is = c.getResourceAsStream("/Manifest.mf"); helpstring = new StringBuffer(); byte b[] = new byte[1]; while (is.read(b) != -1) { helpstring.append(new String(b)); } is.close(); } catch (IOException e) { e.printStackTrace(); } System.out.println(helpstring) } u can parse the helpstring variable to get the fields u require i hope it helps.... rgds manik |
| manik_jandial |
| View Public Profile |
| Find all posts by manik_jandial |
|
I did it nearly that way. Using "/manifest.mf" did not found anything. In your your application it really works?
Using "/META-INF/MANIFEST.MF" finds the incorrect file. The found manifest includes only lines: Manifest-Version: 1.0 Created-By: 1.3.0 (Sun Microsystems Inc.) Thanks anyway for your efforts! Eny other suggestions? |
|
Taking into consideration that the manifest is an integral part of the provisioning/installation process of MIDlets, and apparently you can't really know what's going on with it, why don't you just put those attributes in another text file you bundle with your jar?
shmoove |
|
Although I agree with shmoove, and have since moved my properties to a properties file, the question remains outstanding. Why can't the manifest be read from a resource input stream like anything else?
Anyone? -c |
| colinlawrence |
| View Public Profile |
| Find all posts by colinlawrence |
|
Some things to be aware of:
Entries in the manifest are rewritten by jar.exe, that is they are not in the same order that you put them in once in the jar file, not sure if jar removes any fields. Also, some operators but a size limit on the size of the manifest and the size of the jad so I would recommend against using the manifest as a text resource file. For the same reason I would recommend against using the jad file. Use a separate text file, that way if you need to deal with UTF-8 fonts (for localisation) you won't have to worry about it breaking the manifest or jad file. |
| alex_crowther |
| View Public Profile |
| Find all posts by alex_crowther |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|