What are the types of IO streams?

⭐Column introduction

This column will continue to update various questions about JAVA, including interview questions, JAVA introduction to proficiency, etc.

The update speed is maintained at 3-5 articles per day
Insert image description here

Problem Description

What are the types of IO streams?

Insert image description here

Answer

IO stream refers to the input and output stream, used to transfer data between the computer and external devices. In Java, IO streams are divided into byte streams and character streams, and each stream is divided into input streams and output streams. The following is an introduction to the types of IO streams:

Byte stream:

InputStream: The base class for all byte input streams, providing methods for reading bytes.
OutputStream: The base class for all byte output streams, providing methods for writing bytes.
FileInputStream: used to read bytes from a file.
FileOutputStream: used to write bytes to a file.

Character stream:

Reader: The base class for all character input streams, providing methods for reading characters.
Writer: The base class for all character output streams, providing methods for writing characters.
FileReader: used to read characters from a file.
FileWriter: used to write characters to files.

Buffered stream:

BufferedReader: Provides a buffered character input stream to increase reading efficiency.
BufferedWriter: Provides a buffered character output stream to increase writing efficiency.
BufferedInputStream: Provides a buffered byte input stream to increase reading efficiency.
BufferedOutputStream: Provides a buffered byte output stream to increase writing efficiency.

Object stream:

ObjectInputStream: Input stream for reading objects.
ObjectOutputStream: Output stream for writing objects.

Conversion flow:

InputStreamReader: Converts a byte input stream to a character input stream.
OutputStreamWriter: Converts character output stream to byte output stream.

Byte array stream:

ByteArrayInputStream: An input stream that reads data from a byte array.
ByteArrayOutputStream: An output stream that writes data to a byte array.

Basic type streams:

DataInputStream: Read data of basic data types from the input stream.
DataOutputStream: Writes data of basic data types to the output stream.

Print stream:

PrintStream: Provides an output stream for printing various data value representations.
PrintWriter: Provides an output stream for printing various data value representations.

Guess you like

Origin blog.csdn.net/weixin_50843918/article/details/133103315