java.nio = New I/O
It was introduced to improve performance, scalability, and flexibility in Java I/O operations.
Here’s what it covers:
Feature | java.io (Old I/O) | java.nio (New I/O) |
📚 Style | Stream-based | Buffer & channel-based |
📁 File handling | File | Path, Files |
🔁 I/O type | Blocking only | Blocking & Non-blocking |
⚙️ Performance | Good for simple tasks | Better for large data or high load |
📂 Directory walk | Manual | Built-in (Files.walk()) |
🧠 Learning curve | Easier to start with | More powerful, but more complex |
🛠️ Use case | Small, legacy, simple apps | Modern, scalable applications |