ACCTG 1 Lecture Notes - Lecture 5: Readwrite, Railways Act 1921, Cbuf-Fm
Document Summary
Exception handling and streams lecture6 readfile() openfile(); determinefilesize(); allocatememory(); readfileintomemory closefile(); Calling method may forget to check for error code. Calling method may not know how to fix error. Exception: definition: an exception is an event that occurs during the execution of a program programming for failure that disrupts the normal flow of instructions. Advantages: separating error handling code from "regular" code, propagating errors up the call stack, grouping exceptions. The java language requires that methods either catch or specify all exceptions that can be thrown within the scope of that method!! Insufficientfundsexception ( ammount exceeds balance ); balance = balance amount; throw exception; Designing exception types example of exception handler in= new scanner(system. in); String inputline = in. next(); int age = integer. parseint(inputline); age++; Programs receive information from an external source or send out information to an external destination. A stream is an abstraction of a sequence of bytes.