CS141: Topics for Week 11: Nov 2, 4 & 6, 2015
Computer Science Headlines
ACM Tech News
Continue to work on Lab 8: Arrays
Continue discussion of Arrays from last week.
Ascii (text) file vs binary file
Opening a file
Closing a file
Throwing an Exception
Catching an Exception
- Reading ascii text files using the Scanner and File classes
- Writing to ascii text files using the PrintWriter class
- Opening and closing
- Binary data (anything other than ascii, e.g. images) - can't be represented on a console
- Checking for more data using in.hasNextInt(), in.hasNextDouble(). These return a boolean value.
- Reading words (tokens) vs lines using next()
- Converting Strings to numbers, e.g. using Double.parseDouble, Integer.parseInt()
- Exception Handling; Dealing with errors; How to gracefully survive a crash.
- Throwing an exception
- Catching an exception; Catching multiple exception types
- Types of Exceptions - see Javadoc for the Exception class
- The finally clause - cleaning up no matter what happens, e.g. closing a file
In Class Practice Activities
- Sample Netbeans projects (download and unzip):