Govt Exams
FileChannel supports memory-mapped files and direct buffer manipulation, enabling high-performance I/O operations not possible with traditional streams.
CipherOutputStream allows transparent encryption of data written through it, properly integrating with Java's cryptography framework.
RandomAccessFile allows seeking to the file's end to read only new appended data efficiently.
FileChannel enables non-blocking operations and memory-mapping, offering better performance for large files.
RandomAccessFile allows seeking to any position in the file without sequential reading, ideal for random access.
Pipes require separate threads for reading and writing. Using both in the same thread causes deadlock.
PrintStream (used by System.out) is internally synchronized for thread-safety, unlike other stream classes.
A class must explicitly implement the Serializable interface to be serialized. Static fields are not serialized, and not all classes are serializable by default.
Most streams in Java are idempotent regarding close() - calling it multiple times is safe and subsequent calls typically do nothing.
Java NIO (New I/O) uses ByteBuffer and Channels for non-blocking, scalable I/O operations with better performance than traditional streams.