StringBuffer implements a mutable sequence of characters and it is like a String, but one that can be modified and updated whilst save memory and resources. It is used for the purpose of saving resources whilst working with String Characters or updating a sequence of strings...and not as a mechanism to store data into a file.
To store data into a file, you will need to use the java.io package, and you will have to decide whether to store your data as a stream of characters or as a stream of bytes depending on which works best for you.
Here is a good introductory
tutorial that provides examples on how to store data as a stream of characters or a stream of bytes.
Please note that if you decide to store data as a stream of characters, that you should make use of charsets...so that if you move your application from one machine to another, it will use the correct charset that you have specified.
Greetings
Felissa