COMP 202 Lecture Notes - Lecture 21: Cheat Sheet, Exception Handling, Compile Time

33 views3 pages
jc123 and 40170 others unlocked
COMP 202 Full Course Notes
100
COMP 202 Full Course Notes
Verified Note
100 documents

Document Summary

Comp202 lecture 21 - checked vs unchecekd exceptions and file i/o. A try/catch block allows us to try some code, and if an exception is raised, we can then. An exception that is caught will notcause the program to crash. Unchecked (what we"ve seen up until now); Unchecked: not checked at compile- time. They cause your code to crash at run- time. You are not forced to handle these exceptions. It is up to the programmer to decide if to catch the excptions. Checked: checked at compile time. There are two ways to handle these exceptions: These kind of operations are called file input/output (file i/o). The import statement: import java. io. Writing to a file: (useful to put on a crib sheet for the final as this doesn"t change) Filewriter fw = new filewriter( file. txt ); name of file. Bufferedwriter bw = new bufferedwriter(fw); bufferedwriter takes as input the filewriter. Strting message = hello!\n ; bw. write(message); bw. close(); fw. close();

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents