Java Reference
In-Depth Information
Data File Concepts
Programs often need to read data from a data file or write data to a data file on a
secondary storage device, such as a disk. Storing data in locations within the
computer's memory is temporary; data easily can be overwritten or lost when
the computer is turned off. Therefore, any permanent storage of data should be
on a secondary storage device. Data typically is stored in data files, which are
collections of fields within records.
To read data, a Java program must open a stream to the data file. Once the
data source is streamed, Java reads the information serially. Similarly, a Java pro-
gram can write data to a secondary storage device by opening a stream to the
data and writing the data serially.
Data Hierarchy
Data is organized in a hierarchy, in which each level contains one or more
elements from the level beneath it. The levels in the hierarchy of data, from low-
est to highest, are bit, byte, field, record, and file (Table 8-6).
Table 8-6
Hierarchy of Data
DATA ELEMENT
CONTAINS
DESCRIPTION
EXAMPLE
bit
lowest level
binary digit 0 or 1
Bits can represent any two-state
condition, such as on or off, but
usually are combined with bytes
to represent data
byte
group of related bits
one character or other unit of
01000001 (letter A)
information consisting of
eight bits
field
group of related bytes
individual elements of data,
Ethel
such as a person's first name
record
group of related fields
related groups of fields, such
Ethel Malson
as a person's name, address,
202 N. Van Buren
and telephone number
Albany, MO 64402
(816) 555-5519
file
group of related records
Many related records
Ethel Malson, 202 N. Van
Buren…
Idris Evans, R.R. 1 Box 199…
Elsie Amos, 1306 Minuteman
Dr.…
All data in memory appears as combinations of zeroes and ones, because
electronic devices can assume one of two stable states: off and on. This binary
digit , or bit , is the smallest piece of data a computer can understand. Usually a
bit is combined with other bits to represent data. The combination of bits
within a coding scheme is called a byte . A byte can represent a character, such as
 
Search WWH ::




Custom Search