0% found this document useful (0 votes)
7 views3 pages

Java I/O Streams Overview and Types

The document provides a comprehensive overview of Java I/O Streams, detailing the two main types: Byte Streams and Character Streams, along with their common subclasses. It covers file I/O classes, buffered streams for faster I/O, data and object streams for handling primitive data types and objects, and standard streams for input and output. Additionally, it highlights important methods and common traps for multiple-choice questions related to Java I/O.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Java I/O Streams Overview and Types

The document provides a comprehensive overview of Java I/O Streams, detailing the two main types: Byte Streams and Character Streams, along with their common subclasses. It covers file I/O classes, buffered streams for faster I/O, data and object streams for handling primitive data types and objects, and standard streams for input and output. Additionally, it highlights important methods and common traps for multiple-choice questions related to Java I/O.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JAVA I/O STREAMS - COMPLETE SUMMARY NOTES

1. I/O Stream Basics

- Java I/O is used to read and write data (input/output).

- Stream = flow of data (sequence of bytes or characters).

- Two main types: Byte Streams (InputStream/OutputStream) and Character Streams

(Reader/Writer)

2. Byte Streams

- InputStream for reading bytes

- OutputStream for writing bytes

- Common subclasses: FileInputStream, FileOutputStream, BufferedInputStream, DataInputStream,

ObjectInputStream

3. Character Streams

- Reader for reading characters

- Writer for writing characters

- Common subclasses: FileReader, FileWriter, BufferedReader, PrintWriter, InputStreamReader

4. File I/O Classes

File: Represents a file or directory

FileReader: Reads characters from file

FileWriter: Writes characters to file

FileInputStream: Reads bytes

FileOutputStream: Writes bytes


5. Buffered Streams

- Faster I/O using buffers

- BufferedReader, BufferedWriter, BufferedInputStream, BufferedOutputStream

6. Data Streams

- Reads/writes primitive data types in binary form

- DataInputStream (readInt, readUTF), DataOutputStream (writeInt, writeUTF)

7. Object Streams

- Reads/writes objects (must be Serializable)

- ObjectInputStream, ObjectOutputStream

8. PrintStream & PrintWriter

- For formatted output

- PrintStream: byte-based (used in [Link])

- PrintWriter: character-based (used for text files)

9. Standard Streams

[Link] - standard input (keyboard)

[Link] - standard output (console)

[Link] - standard error (console)

10. RandomAccessFile

- Read/write at any position using seek()

- Not part of InputStream/OutputStream

11. Important Methods


read(), read(byte[]), write(), write(byte[]), close(), flush()

12. Key Concepts for MCQs

- [Link]() gives size in bytes

- [Link] is InputStream; [Link] is PrintStream

- read() returns -1 at EOF

- Data streams must match read/write order

- Object streams need Serializable

- File does not read/write content

Common MCQ Traps:

- Confusing read() vs readLine()

- Mixing byte/character streams

- File class does not read/write data

- [Link]() is invalid without wrapper

You might also like