Chapter 1
Filing Information with the Streams Library
IN THIS CHAPTER
Seeing the need for a streams library
Opening a file
Dealing with errors
Working with flags to customize your file opening
You’ve heard of rivers, lakes, and streams, and it’s interesting just how many common words are used in computer programming. That’s handy, because it lets programmers use words they already know with similar meaning. Using common terms makes it easier to visualize abstract concepts in a concrete way.
Most programmers think of a stream as a file — the type stored on a hard drive, Universal Serial Bus (USB) flash drive, or Secure Digital (SD) card. But streams go beyond just files. A stream is any type of data structure that you can access as a flow of data, essentially a sequence of bytes. Streams are used to access all sorts of devices, such as smart speakers. Rather than just fill a 500MB data structure and then drop it onto the hard drive, you write your data piece after piece; the information goes into the file.
Streams go further than a wide variety of devices, however. Opening an Internet ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access