I have developed J2ME application that read data from product.txt file located in binary package using following code
InputStream is = getClass().getResourceAsStream("/product.txt");
int size = is.available();
byte bytes[] = new byte[size];
is.read(bytes, 0, size);
str = new String(bytes, 0, size);
Now I want’s to update product.txt file located in binary package using J2ME code.
I have tried Following code to get relative path of product.txt
String path=getClass().getResource("/product.txt").getPath();
But it does not works on J2ME platform.
How to get relative path Of product.txt file located in binary package?
You can’t change a file that is baked in to the jar. You’ll notice that there is no equivalent of
getResourceAsStream()that offers anOutputStream.