I/O & NIO
Interacting with files, sockets, and byte streams is fundamental to any server-side Java application. The classic
java.iopackage uses streams and decorator patterns. NIO.2 (Java 7+) replaced it withPath,Files, and channels for scalable, non-blocking I/O. Serialization is important to know — but mostly to understand why it should be avoided in modern code.
What You'll Find Here
Notes are being added. Planned topics:
| Topic | Description |
|---|---|
| File I/O Basics | FileInputStream/FileOutputStream, BufferedReader/BufferedWriter. |
| NIO.2 (Java 7+) | Path, Files utility, Files.walk, WatchService. |
| I/O Streams | InputStream/OutputStream hierarchy; decorator pattern; try-with-resources. |
| Channels & Buffers | NIO Channel, ByteBuffer; key concepts for understanding reactive I/O. |
| Serialization | Serializable, transient, serialVersionUID; why JSON/Protobuf are preferred. |
Learning Path
- File I/O Basics — understand the classic stream model even if you'll mostly use NIO.2.
- NIO.2 —
Files.readAllLines,Files.write, andFiles.walkare the day-to-day APIs. - I/O Streams — the decorator pattern (wrapping streams) is tested conceptually in interviews.
- Serialization — understand the security risks and why it's avoided; know
serialVersionUID.
Related Domains
- Core Java —
try-with-resourcesfrom exceptions and basic type handling underpin I/O. - Multithreading & Concurrency — NIO non-blocking channels are critical for understanding async I/O in Netty and Reactor.
- Spring Data — file storage and streaming in Spring builds on NIO.2.