Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 18
Registered: ‎08-23-2012
My Device: Blackberry 9990
Accepted Solution

How can i write to a text file without erase it previous content

Hi i'm Luis

 

Code:

 

FileConnection conn = (FileConnection) Connector
.open("file:///SDCard/xxx/Read");
if (!conn.exists()) {
conn.create();
}
if (conn.exists() && conn.fileSize() == 0) {
OutputStream out = conn.openOutputStream();
String incroversa_message = "text";
out.write(text);
out.write(text);
out.write(text);
out.write(text);
out.write((text));
out.write(text);
out.write(text);
out.close();
conn.close();
}

 


The code work but the problem is that when i try to do another write erase the previous and write the new write.

 

 

Thanks.

Developer
Posts: 246
Registered: ‎09-30-2010
My Device: Z10, Onyx2

Re: How can i write to a text file without erase it previous content

2 solution...

read the the file and get the content. then write the file with the content + new content

or you could get the file content and append it with new content
Contributor
Posts: 18
Registered: ‎08-23-2012
My Device: Blackberry 9990

Re: How can i write to a text file without erase it previous content

Thanks.

:-)