Java Unit - 3
Java Unit - 3
At its core, I/O in Java revolves around the idea of streams. A stream is a sequence of data that flows from
a source to a destination. Java provides two main types of streams:
1. Byte Streams: These streams handle data in the form of individual bytes (8-bit units). They are
suitable for all types of data, including binary files (like images, audio, video) and text files (where
each character is treated as one or more bytes depending on the encoding).
2. Character Streams: These streams handle data in the form of characters. They are specifically
designed for text-based data and automatically handle character encoding and decoding. This
makes them more convenient and efficient for working with text.
Input and Output (I/O) are fundamental concepts used for reading data from input sources (like the
keyboard or files) and writing data to output destinations (like the screen or files). Java provides several
classes and methods to handle I/O operations, which are part of the java.io, java.util, and
java.nio packages.