java.io and java.nio

FileOutputStream

The FileOutputStream class in Java is used to write raw bytes to a file. It is part of the java.io package and is typically used for binary data (images, audio, etc.) or writing bytes to text files. Commonly Used Constructors and Methods Simple Program Mahesh wants to write the message “Hello LotusJavaPrince!” into a file …

FileOutputStream Read More »

PipedWriter

PipedWriter is a character stream class in the java.io package used to write characters to a pipe. This pipe can be connected to a PipedReader which reads the characters written by PipedWriter. This mechanism facilitates inter-thread communication where one thread writes data, and another reads it. Commonly Used Constructors and Methods Simple Program Using PipedWriter …

PipedWriter Read More »

Writer

Writer is an abstract class for writing streams of characters in Java. It is the superclass for all classes that write character output, such as FileWriter, BufferedWriter, PrintWriter, etc.It is the character-based counterpart of OutputStream and handles text data efficiently across platforms with Unicode support. Commonly Used Methods Simple Program – Writing to a File …

Writer Read More »

PipedOutputStream

PipedOutputStream is a class in the java.io package used to write data to a communication pipe, where another thread can read the data using a connected PipedInputStream. Together, they form a producer-consumer style inter-thread communication channel. This mechanism is helpful for simulating streaming, pipelines, or in-memory communication between threads without using shared memory or files. …

PipedOutputStream Read More »

ByteOrder

ByteOrder is a final class that defines byte ordering—endianness—used when reading or writing multibyte data types (like int, float, etc.) into a ByteBuffer. What is Byte Order? Byte order (endianness) refers to the order in which bytes are stored in memory: Big-endian: Most significant byte is stored first. Little-endian: Least significant byte is stored first. …

ByteOrder Read More »

CompletionHandler

The CompletionHandler is an interface used for handling the result of an asynchronous I/O operation (like AsynchronousFileChannel or AsynchronousSocketChannel). Interface Definition Program 1: Simple Asynchronous File Read LotusJavaPrince wants to read a file asynchronously using AsynchronousFileChannel, and Mahesh is tasked with writing the result to the console when the operation completes successfully or fails. Problem …

CompletionHandler Read More »

Introduction to Asynchronous and Non Blocking I/O

Java I/O (Input/Output) operations play a critical role in reading data from sources (like files, sockets, or databases) and writing data to destinations (like disk files or client connections). Traditionally, Java used blocking I/O, which was simple but inefficient for high-performance or concurrent applications. To overcome this limitation, Asynchronous and Non-Blocking I/O models were introduced …

Introduction to Asynchronous and Non Blocking I/O Read More »

Scroll to Top