Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
kaddy
Posts: 158
Registered: 08-20-2009

Writing to a file

I get the content of a entire xml file into a string ..i need to write this string to a xml file ...how can i do that...and where will the file be store in the simulator...?

 

Kaddy

Please use plain text.
Developer
kaddy
Posts: 158
Registered: 08-20-2009

Re: Writing to a file

I need to do this for the version 4.2.1...please let me know...

 

Kaddy

Please use plain text.
Developer
peter_strange
Posts: 13,585
Registered: 07-14-2008

Re: Writing to a file

There is a sample writing a file here, that might get you going:

 

How To - Capture and save a screen shot
Article Number: DB-00752
http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/...

You will find the FileExplorerDemo also very useful.

 

I presume you want to write to the SD Card?

Please use plain text.
Developer
kaddy
Posts: 158
Registered: 08-20-2009

Re: Writing to a file

this we can use only with 4.3 and later i am using 4.2.1 ..and i want to be able to take the printout of the file many times to check..so file explorer is not a option....

 

Kaddy

Please use plain text.
Developer
peter_strange
Posts: 13,585
Registered: 07-14-2008

Re: Writing to a file

The KB article I gave you is 4.3 only because it does a Screenshot.  That was not why I pointed you at it. 

 

Do you see the code it uses to write a sequence of bytes out?  That code will work in 4.2.1.  So all you have to do is copy that code, and turn your String into bytes (which you can do with getBytes()) rather than doing the Screenshot

 

FileExplorerDemo is very useful, because it will show you how to traverse directories, you might want to do that in order to check what files you already have, so you don't overwrite something.

 

I suspect that with these and the API documentation, you have enough to do the coding you require. 

Please use plain text.