15.4 Summary


15.4 Summary

This chapter explains how to detect and handle exceptions. These errors indicate abnormal conditions during the execution of the program. An exception is detected in a try block, which encloses a sequence of statements that might throw an exception. The exception is handled in a catch block, which encloses the sequence of statements that implement some action in response to the exception. The simplest way to handle an exception is to display information about the exception and terminate the program.

An I/O stream is a sequence of bytes in the input direction or in the output direction, which is treated as a source of data or a destination of data. I/O streams are normally connected with files. The two general types of files are text and binary files. Only text files are explained.

Most of the statements for opening, reading, and writing files throw exceptions. Therefore, these statements must be placed in a try block. The input and output with text files are carried out to or from a text line, which is a string. If the data is numeric, then conversion to or from the appropriate numeric type is necessary.




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