The basic idea of  IOStreams is
  • Storing and reading data from files
  • reading data from keyword
First let us understand some basic terminology.

Persistent media:

  • The environment that allows us to store data permanently is called persistent media.
  • We can store data permanently in three places
  1. File
  2. Database
  3. Remote Computer 

Persistence:

  •  The process of storing data permanently in a persistence media.

Persistence Logic:

  • The logic that persist data in a persistence media is called persistence logic.
  • Ex: IOStreams based logic, JDBC logic, Networking based logic.

Persistence Technologies:

  •  The technology that provides API to develop persistence logic is called persistence technology.
  • Well known persistence technologies are 
  1. IOStreams : to persist data in files
  2. JDBC, EJB, Hibernate: to persist data in db
  3. Networking: to persist data in remote computer

Where can we store data permanently? 

  • In persistence medias either files or in databases.
  • Storing data in variables and arrays  is temporary. Data will be lost when a local variable goes out of scope or when the program terminates.
  • programmers use files or databases for long term storage of large amount of data. it is available even after termination of the program. We refer to data maintained on files as persistent data, because the data exists beyond the duration of the program execution.
  • To store data in files and databases  Oracle has given in  built API. We all need to do is creating the particular class object calling methods for storing and reading data from that persistence media.
  • IOStreams API is given to store and read data from files
  • JDBC API is given to store and read data from Databases. 

How java application can store or read data from a file?

  • Using stream object.

Introduction to Streams:

  • Stream is logical connection between java program and a file.
  • To store the data in the persistence media there should be a way to connect to persistence media from java application either physically or logically. Stream provides logical connection.
  • "Its a continuous flow of data between java program and persistence media"

Direction of stream flow:

  • Stream has a direction and its direction depends on the viewer's view. In java the viewer is java Application. If you look from Java Application it is sending out from Java Application.


Type of Streams:

  • Generally Streams are divided in to two types based on data flow direction.
  1. InputStream.
  2. OutPutStream.

InputStream:

  • The stream that allows data to come into the java application from the persistent media is called input Stream.

OutPutStream:

  • The stream that allows data to send out from the java application to be stored into the persistence media is called OutPutStream.
  • Basically InputStreams are used to read data from a persistence media , and Oputstreams are used to write or store  data in a persistence media from a java application

Types of Java Streams:

  • In java we are allowed to send data through streams only either in the format of bytes or characters. So based on the type of the data passed through streams .
  • In java streams are divided in to two types.
  1. Binary Streams.
  2. Character Streams.

 1.Binary Streams: 

  • The streams which read and write data in the format of  bytes is called Character streams.

 2.Character Streams:

  • The streams which read and write data in the format of  characters is called Character streams.
Java Streams

Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

1 comments for IO Streams

Select Menu