CH09 - Chapter 9 Streams and File I/O Overview of Streams...

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

View Full Document Right Arrow Icon
Chapter 9 Chapter 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 1

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

View Full DocumentRight Arrow Icon
Chapter 9 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 » input can be automated (rather than entered manually) 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 2
Chapter 9 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 » SavitchIn is an input stream A stream connects a program to an I/O object » System.out connects a program to the screen » SavitchIn connects a program to the keyboard
Background image of page 3

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

View Full DocumentRight Arrow Icon
Chapter 9 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" Binary files : the bits represent other types of encoded information, such as executable instructions or numeric data » these files are easily read by the computer but not humans » they are not "printable" files actually, you can print them, but they will be unintelligible "printable" means "easily readable by humans when printed"
Background image of page 4
Chapter 9 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 Occasionally output files Java Binary Files Executable files (created by compiling source files) Usually input files Usually output files
Background image of page 5

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

View Full DocumentRight Arrow Icon
Chapter 9 Text File I/O
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/17/2008 for the course COMP SCI 201 taught by Professor Durga during the Spring '08 term at Wentworth Institute of Technology.

Page1 / 50

CH09 - Chapter 9 Streams and File I/O Overview of Streams...

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

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