Tutorial #14 : File I/O

What is File I/O?

Java I/O stream is the flow of data that you can either read from, or you can write to.
It is used to perform read and write operations in file permanently. Java uses streams to perform these tasks. Java I/O stream is also called File Handling, or File I/O. It is available in java.io package. Java.io package provides classes for system input and output through files, network streams, memory buffers, etc.


                                

Some input-output stream will be initialized automatically by the JVM and these streams are available in System class as inout, and err variable.
  • In reference refers to the default input device, i.e. keyboard.
  • Out and err refers to the default output device, i.e. console.
Prepare yourself for the industry by going through this Top Java Interview Questions and Answers!

Streams:

Streams are the sequence of bits(data).
There are two types of streams:
  • Input Streams
  • Output Streams
Input Streams: Input streams are used to read the data from various input devices like keyboard, file, network, etc.

Output Streams: Output streams are used to write the data to various output devices like monitor, file, network, etc.Some input-output stream will be initialized automatically by the JVM and these streams are available in System class as inout, and err variable.
  • In reference refers to the default input device, i.e. keyboard.
  • Out and err refers to the default output device, i.e. console.

Streams:
Streams are the sequence of bits(data).
There are two types of streams:
  • Input Streams
  • Output Streams
Input Streams: Input streams are used to read the data from various input devices like keyboard, file, network, etc.

Output Streams: Output streams are used to write the data to various output devices like monitor, file, network, etc.
There are two types of streams based on data:
  • Byte Stream: used to read or write byte data.
  • Character Stream: used to read or write character data.


Byte Input Stream:

  • These are used to read byte data from various input devices.
  • InputStream is an abstract class and it is the super class of all the input byte streams.

Byte Output Stream:

  • These are used to write byte data to various output devices.
  • Output Stream is an abstract class and it is the superclass for all the output byte streams.

Character Input Stream:

  • These are used to read char data from various input devices.
  • Reader is an abstract class and is the super class for all the character input streams.

Character Output Stream:

  • These are used to write char data to various output devices.
  • Writer is an abstract class and is the super class of all the character output streams.


Comments