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

Java_IO_Streams_Summary

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)
4 views3 pages

Java_IO_Streams_Summary

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
You are on page 1/ 3

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 System.out)

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

9. Standard Streams

System.in - standard input (keyboard)

System.out - standard output (console)

System.err - 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

- File.length() gives size in bytes

- System.in is InputStream; System.out 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

- System.in.readLine() is invalid without wrapper

You might also like