how to write into a text file in j2me

R

rajesh

Hi every one,

I am doing a project in j2me and in that i need to add and modify my
text file,
which is grouped in the jar.

As i know, by using class.getResourceAsStream(filename) this method we
can read that file.

but i want to write into that textfile.
this iam not getting.
plz any body help me.
 
D

Darryl L. Pierce

rajesh said:
I am doing a project in j2me and in that i need to add and modify my
text file,
which is grouped in the jar.

No, you cannot modify the contents of the JAR file once it's installed onto
a handset.
As i know, by using class.getResourceAsStream(filename) this method we
can read that file.

but i want to write into that textfile.

You can't. You can only write to a record store.

--
Darryl L. Pierce <[email protected]>
Homepage: http://mcpierce.multiply.com/
"McVeigh's lawyer got him the death penalty, which, quite frankly,
I could have done." - Jon Stewart
*** Free account sponsored by SecureIX.com ***
*** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.com ***
 
J

JScoobyCed

rajesh said:
Hi every one,

I am doing a project in j2me and in that i need to add and modify my
text file,
which is grouped in the jar.

As i know, by using class.getResourceAsStream(filename) this method we
can read that file.

but i want to write into that textfile.
this iam not getting.
plz any body help me.

The only way one can write to the mobile File System in J2ME is to use
(if supported) the JSR-75: FileConnection and PIM API.
Additionaly, you can't modify a text file on the mobile if it is in the
JAR running your application.
 
Joined
Jan 7, 2009
Messages
2
Reaction score
0
i it possible to write a content in text file that is present out side of the jar using J2me..

i am having a jar file and text file.. from jar i want to write a code to add a content in text file..

is it possible???
 
Joined
Feb 20, 2010
Messages
1
Reaction score
0
Yes it possible..

Yes it is possible to Read/Write file in Mobile, But need to use Spelical API that are generally restricted by all mobile device. We need develop it as trusted application. I have develop it in NetBean 6.5 and with Emulator it Work Perfect But Mobile device show me ‘ Application Not Authorized to access the restricted API ’

This is my Status with IO operation IF any ONE has idea Please HELP ME…

My Code :
Just import import javax.microedition.io.file.FileConnection;
And try below code

try
{
FileConnection fconn = (FileConnection)Connector.open("file:///c:/masterlist.txt", Connector.READ_WRITE);
if (!fconn.exists())
{
fconn.create(); }
else
{ /*Do As Like*/ }
}
catch (IOException ioe)
{
System.out.println("IOException: " + ioe.getMessage());
}
 
Joined
Jun 1, 2011
Messages
1
Reaction score
0
file access

hi i m using netbeans.
In jar file when i view the contents it gives
hello/res.txt

And when i try to open the contents of file using
InputStream is = getClass().getResourceAsStream("/hello/route.txt");
Its throwin exception

why?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top