This content has been marked as final. Show 10 replies
It's easier than you can imagine.
The root needs three slashes:
Connector.open("file:///c:/myfile.txt;append=true", Connector.WRITE );
You will then have another problem, tho. I I just one step after and the line of code will generate a file called: c:/myfile.txt;append=true
I have really no idea yet, how to append data to a file... probably reading everything and rewriting it, but I hope there is another way.
I'll keep searching.
I tried the same method with all necessary precautions as mentioned but the appl just hangs. To be more specific, the OutputConnection object is not able to open the OutputStream.
relevant code ::
String uri = "file:///c:/test.txt";
OutputConnection conn = (OutputConnection)Connector.open(uri, Connector.WRITE);
OutputStream out = conn.openOutputStream();
Can you help ?
I have same problem.
Can anybody get success to writting file from j2me MIDlet?
plz give me releted guidance or code for that..
Have you find the answer?
ultimately i used FileConnection API
The directory is most likely write-protected. Go down serveral sub-directories(like image folder), the code above should work.
Its most probable reason is that you are trying to access a file that doesn't exist. J2Me doesn't take root of your system. If you are using WTK toolkit then put your file in
Connector.open("file:///root1/myfile.txt;append=true", Connector.WRITE );
Note: All the slashes are forward.
i tried the example using the follwoing code:
OutputConnection connection = (OutputConnection)
Connector.open("file:///root1/myfile.txt", Connector.WRITE );
and it works fine.
but if i add append=true, as "file:///root1/myfile.txt;append=true"
it does not work. but i want to append the file. could you please tell me what to do?
You can use the following code:
FileConnection fileConnection = (FileConnection) Connector.open(path, Connector.WRITE);
OutputStream outStream = fileConnection.openOutputStream(fileConnection.fileSize());
Zombie thread, locking.