Reputation: 187537
I want to append the content of fileA to fileB. As fileA is large, I would like to do this in a memory-efficient way, i.e. without reading the entire content of fileA into memory.
Upvotes: 1
Views: 1080
Reputation: 399871
This way, you will read the entire contents of fileA into memory, but not all at once. A suitable block size needs to chosen, and I would recommend something pretty big if you have the RAM to spare. A large block size minimizes the number of OS calls. Try 1 MB (if you're in a typical desktop environment, that should be fine).
Upvotes: 3