Page 360 - Cs_withBlue_J_C11_Flipbook
P. 360
For example, a sample data file “Application.dat” that stores the details of candidates applying for an interview for the
post of a programmer is given below.
Fields
Application_Number Applicant_Name Mobile_No Mail_ID
P100101 Ajay Nanda 9876501210 ajay.n@gmail.com
P100102 Geeta Suresh 7665743781 geeta.pune@yahoomail.com
P100103 Akash Singh 7453523544 akash.b2002@rediffmail.com
Record
In Java, mainly two types of files are used to store data which are as follows:
• Text Files: The files that store data in the form of human-readable text are known as text files. These files contain
data as a sequence of characters in the form of ASCII or UNICODE characters. A text file is identified by .txt extension.
In this type of file, each line is terminated by an End of Line (EOL) character.
• Binary Files: Binary files are not in human-readable form. These are machine-readable files. A binary file stores data
in the form of 0s and 1s. There is no need to put a comma, space, or an end-of-line character in the binary files.
12.4 INTRODUCING STREAMS
In Java, a sequence of data is called a stream. In other words, a stream can be defined as a path along which the data
travels from an input device to a program and from a program to an output device. It is a communication medium
through which the data is stored and retrieved. The stream used to read data from various input devices is known
as the input stream. The stream used to write data to various output devices is known as the output stream. These
streams are used to perform input/output operations on files. The java.io package provides all the classes to perform
these operations. Streams in Java are of two types:
Streams in Java
Byte Stream Character Stream
Let us learn about these in detail.
12.4.1 Byte Stream
Byte-oriented input/output is performed on binary files that store data in machine-readable form. Byte stream class
handles data in bytes. Java has two abstract classes which are the superclasses of all other classes used to read or write
a stream of bytes. These two classes are as follows:
Byte Stream Classes
InputStream OutputStream
FileInputStream DataInputStream FileOutputStream DataOutputStream
358358 Touchpad Computer Science-XI

