Java Streams and Input / Output operations

Introduction

This lesson covers the basic input / output operations in Java.I am going to focus on Input / Output Streams , which are the most powerful feature of Java to address the Input / output operations.This lesson covers the streams and Random access files.

What is a Stream in Java

A stream is nothing but a sequence of data.In a stream data flows from the source to destination.We can think it as a pipe which is used to transfer data through it.Programs uses streams to transfer data from program and to.General type of streams are Input / Output Streams.In a java program Input /Output Stream represents a source (sender) of data and a destination (receiver) of data.The source and destinations can be files,disks,devices and other programs e.t.c . 

Streams support many types of data like binary data,primitive types and objects e.t.c.Model of a stream is given below.

Input Stream     :  These are the streams which are used for reading data from data source one item at a time.
OutputStream  These are the streams which are used for writing data to destination one item at a time.

A package in which  all input / output streams addressed  in java is java.io package.Basically, There are four types of streams available in java is given below.
  • ByteStream - for use of binary inputs and outputs and raw data
  • CharacterStream - for use in input /output of character data.
  • BufferedStream- for optimizing the input and output by buffering
  • Scanning and Formatting - for reading the formatted text
  • Object Stream- - for use with Input /Output of objects
  • DataStream --- handles binary input /output of primitive types of data and Strings
  • CommandLine Input/Output  -- for use of console input / output
These stream are explained clearly with examples in the next lessons.You can go to that lessons by clicking the respective links.

We are quite happy to cut it into many small useful pieces

0 comments:

Post a Comment