Math107Ch9 - Introduction To Scientific Programming Chapter...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
Introduction To Scientific Programming Chapter 9 – Stream & File I/O
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
S.Horton/107/Ch. 8 Slide 2 Lecture Overview On Exception Handling I. Basic Exception Handling A. B. Syntax C. Java Exception Classes I. Real-World Strategies A. Design-Time Error Trapping B. Un-Expected Error Control C. “Anticipated” Error Control I. Wrap-Up A. Book Case Study B. Extra Syntax
Background image of page 2
S.Horton/107/Ch. 8 Slide 3 I. Exception Handling - Background Handling errors is one of the most critical and practical aspects of programming today. The goal of error handling – no “lock-ups”/”blow- ups” or crashes! Recover (if you can) from errors. My theory: There are more ways for things to go wrong than right. Some believe that you can actually write as much code for error control and recovery as the application itself.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Chapt er 9 Overview of Streams and File I/O Text File I/O Binary File I/O File Objects and File Names Streams and File I/O
Background image of page 4
S.Horton/107/Ch. 8 Slide 5 I/O Overview I/O = Input/Output In this context it is input to and output from programs Input can be from keyboard or a file Output can be to display (screen) or a file Advantages of file I/O permanent copy output from one program can be input to another Note: Since the sections on text file I/O and binary file I/O have some similar information, some duplicate (or nearly duplicate) slides are included.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
S.Horton/107/Ch. 8 Slide 6 Streams Stream : an object that either delivers data to its destination (screen, file, etc.) or that takes data from a source (keyboard, file, etc.) it acts as a buffer between the data source and destination Input stream : a stream that provides input to a program Output stream : a stream that accepts output from a program System.out is an output stream
Background image of page 6
S.Horton/107/Ch. 8 Slide 7 Binary Versus Text Files All data and programs are ultimately just zeros and ones each digit can have one of two values, hence binary bit is one binary digit byte is a group of eight bits Text files : the bits represent printable characters one byte per character for ASCII, the most common code for example, Java source files are text files so is any file created with a "text editor"
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
S.Horton/107/Ch. 8 Slide 8 Java: Text Versus Binary Files Text files are more readable by humans Binary files are more efficient computers read and write binary files more easily than text Java binary files are portable they can be used by Java on different machines Reading and writing binary files is normally done by a program text files are used only to communicate with humans Java Text Files Source files Occasionally input files Java Binary Files Executable files (created by compiling source
Background image of page 8
Slide 9 Text File I/O Important classes for text file output (to the file) PrintWriter FileOutputStream Important classes for text file
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 56

Math107Ch9 - Introduction To Scientific Programming Chapter...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online