How to save data in a buffer in Arduino

Maybe the Serial Input Basics thread can give you some ideas.

Although it's written for Serial communication, the principles can be applied to basically anything (file read, network read, ...).

Why do you want / need to save to buffer first before writing to SD?