Advantages to Text Files
• Easy to check the contents (type or cat it, or use an
editor)
• Very flexible structure because of end-of-line
delimiters. Each line can be a different length
• Can check the read/write logic by examining the file
on the console.
• Generally portable from one computer platform to
another.
• Can be quite large. (A double can need up to about
20 characters.)
Advantages to Binary Files
• Faster to read and write than text files (especially for
numeric values)
• For mostly numeric data, they require less disk space
than text files (to hold equivalent amount of data)
• Programs can be simpler due to the ability to write
multiple records in one statement.
• Typically much smaller. (A double is usually 8 bytes.)
4/23/2015
14
When to use Text Files
• When all the data to be stored are character
strings, and the strings are many different
lengths.
• When you need your data to be humanreadable.
• When you need to be able to write a file on
one computer platform, and read it on
another.
When to use Binary Files
• When much of the data to be stored is
numeric.
• When there is a lot of data to be stored.
• When the data to be stored all have the same