Chapter 15: Exceptions and IO


15.1 Introduction

Robust programs should take specified actions when errors occur. The most common type of runtime errors are division by zero, array indexing out of bounds, variable value out of range, illegal reference, and I/O errors.

An exception is an error or an unexpected condition that occurs while the program executes. The mechanism for detecting these errors or conditions and taking some action is called exception handling.

All input/output is carried out with streams, except with GUIs. A stream is a sequence of bytes; the direction of the flow of data determines whether it is an input or an output stream—either incoming from a source or directed toward a destination.

Input and output files are associated with I/O streams. The various class packages allow the programmer to open, process, and close files.

This chapter first presents the basic concepts associated with exceptions; second, it applies exception handling in discussing I/O streams and files.




Object-Oriented Programming(c) From Problem Solving to Java
Object-Oriented Programming (From Problem Solving to JAVA) (Charles River Media Programming)
ISBN: 1584502878
EAN: 2147483647
Year: 2005
Pages: 184

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net