Chapter 10. Writing Files
In this chapter, you'll be looking at ways in which basic data can be written to a file using the new file input/output capability that was introduced in the 1.4 release of the JDK and that continues in JDK 5.0. This mechanism for file I/O largely superseded the read/write capability provided by readers and writers from the java.io package when applied to file streams. Since the new file I/O does everything that the old capability does, and does it better, I'll focus just on that.
In this chapter you'll learn:
The principles of reading and writing files using the new I/O capability
How you obtain a file channel for a file
How you create a buffer and load it with data
What view buffers are and how you use them
How you use a channel object to write the contents of a buffer to a file
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