Agregar texto de manera eficiente a y en Android

There is one very nice feature in shell

por ejemplo

# "asd" > myfile.txt

puts "asd" in myfile.txt if the file exist first it is deleted then it is created and the content is put in the file.

pero si

# "asd" >> myfile.txt

and if the file exist then the "asd" will be just added to the end of the file.

well I need some EFFICIENT algorithm that do exactly this.

I have very large text file and all I want to do is to write something to the end, but it must be very efficient I do not want to waste resources on stupid things like read the whole content concatenate and write...

preguntado el 01 de febrero de 12 a las 14:02

2 Respuestas

I know the general concepts about files. One thing which is useful for your case is opening a file in append mode. If you open a file in append mode and trying to write data to it, it just append(adds at the end of file) the given data.

Try to search for similar functionality in android API. This is general feature of File System. In linux also we have familiar with this type of file operations.

Espero que te ayude.

Respondido 01 Feb 12, 18:02

Is este Qué estás buscando.

Respondido 01 Feb 12, 18:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.