Java.Streams.Name the main classes of input/output streams.

✅ Main Classes of Input/Output Streams

🔹 1. Byte Streams

Use these for binary data (files, images, audio, etc.)

📥 Input Streams (read bytes):

  • InputStream (abstract base class)
  • FileInputStream – reads bytes from a file
  • BufferedInputStream – adds buffering
  • ByteArrayInputStream – reads from a byte array
  • DataInputStream – reads primitive types (int, double, etc.)
  • ObjectInputStream – reads serialized Java objects
  • PipedInputStream – used for inter-thread communication

📤 Output Streams (write bytes):

  • OutputStream (abstract base class)
  • FileOutputStream – writes bytes to a file
  • BufferedOutputStream – adds buffering
  • ByteArrayOutputStream – writes to a byte array
  • DataOutputStream – writes primitives
  • ObjectOutputStream – writes serialized objects
  • PipedOutputStream – connects to PipedInputStream

🔹 2. Character Streams

Use these for text (Unicode characters)

📥 Readers (read characters):

  • Reader (abstract base class)
  • FileReader – reads from a file
  • BufferedReader – efficient line-by-line reading
  • CharArrayReader – reads from a char array
  • StringReader – reads from a string
  • InputStreamReader – bridges byte → character stream

📤 Writers (write characters):

  • Writer (abstract base class)
  • FileWriter – writes to a file
  • BufferedWriter – buffered writing
  • CharArrayWriter – writes to char array
  • StringWriter – writes to string
  • OutputStreamWriter – bridges character → byte stream

🧠 Summary Table

CategoryInput (Read)Output (Write)
Byte StreamsInputStream and subclassesOutputStream and subclasses
Char StreamsReader and subclassesWriter and subclasses
This entry was posted in Без рубрики. Bookmark the permalink.

Leave a Reply

Your email address will not be published.