Insert some trings into a big file?

L

Lingyun Yang

Hi every one,

I need some help on inserting some strings into a big file.
I know if it's appending, I can use append mode when open the
file, but how about the insert ? Read out to a buffer, insert
to the buffer and then write back? since it's a 10-20M file.
and the inserting is once every 10-20 sec.
In this method, the program would be very slow

Thank you!
 
K

Kevin Goodsell

Lingyun said:
Hi every one,

I need some help on inserting some strings into a big file.
I know if it's appending, I can use append mode when open the
file, but how about the insert ? Read out to a buffer, insert
to the buffer and then write back? since it's a 10-20M file.
and the inserting is once every 10-20 sec.
In this method, the program would be very slow

There is no standard way short of re-writing the whole file. Your OS
and/or file system might not even support inserting -- I don't think
there are many that do (but I could be wrong).

You can always check your systems documentation for a way of doing what
you want, or reconsider your algorithm (perhaps changes could be cached
in memory, and written to the file only occasionally, for example).

-Kevin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,164
Messages
2,570,898
Members
47,439
Latest member
shasuze

Latest Threads

Top