Question

There is one very nice feature in shell

for example

# "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.

but if

# "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...

Was it helpful?

Solution

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.

I hope it may help you.

OTHER TIPS

Is this what you are looking for.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top