Govt Exams
mark() records the current position in the stream, and reset() returns to that marked position, useful for lookahead operations.
SequenceInputStream concatenates multiple input streams, reading from them sequentially as if they were a single stream.
GZIPInputStream decompresses GZIP-compressed data, allowing transparent reading of compressed files as normal streams.
The transient keyword marks fields that should not be serialized, useful for excluding sensitive data or non-serializable objects.
BufferedReader combined with custom parsing logic (using split or regex) handles variable-length fields better than fixed-format alternatives.
The unread() method of PushbackInputStream allows you to push bytes back into the stream so they can be read again.
PrintWriter is synchronized, making it thread-safe. Other stream classes are not inherently thread-safe and require external synchronization in multi-threaded contexts.
If no charset is explicitly provided, InputStreamReader uses the platform's default charset, which varies by system configuration.
SAX parsers and streaming XML parsers process XML sequentially without loading the entire document, making them ideal for large files.
For real-time applications requiring minimal latency, smaller buffer sizes and frequent flushing ensure data is processed immediately rather than waiting for buffer to fill.