Stream I/O

"What goes in, must come out."
—Glenn and Andrew


In this chapter, you will learn how to utilize streams and files in your games. Files are especially useful if you do not have access or simply do not wish to use a database for storing your data. In fact, for single-player games, it really makes more sense to use files to save (for example, players' saved games or high scores). An important use of files is for loading in specific game data, such as a file storing level data. The key aspects of this chapter cover writing data to a file, reading data in from a file, and then finally how to save and retrieve entire objects (classes) to and from a file by using serialization.