lec6 - COMP201 Java Programming Topic 6: Streams and Files...

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

View Full Document Right Arrow Icon
COMP201 Java Programming Topic 6: Streams and Files Reading: Chapter 12
Background image of page 1

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

View Full DocumentRight Arrow Icon
COMP201 Topic 6 / Slide 2 Outline Introduction and overview Writing and reading text files Writing and reading binary files Writing and reading objects File management
Background image of page 2
COMP201 Topic 6 / Slide 3 Introduction and Overview When talking about IO, we need to consider files Location: blocks of main memory – local file system – over the net Format: – text or binary – zipped or not zipped Access mode: – plain sequential, – buffered, – pushback, – Random Java has classes for all possible combinations.
Background image of page 3

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

View Full DocumentRight Arrow Icon
COMP201 Topic 6 / Slide 4 Introduction and Overview Java streams provide an abstraction of files at different locations: Local files and files from the net are handled in essentially the same way. In this lecture, we deal with only files on local machine. Java has many (60+) stream classes for various file formats and access modes We will cover only a few commonly used classes. What follows is an overview of those 60+ classes. Classes for reading text files Classes for writing text files Classes for reading binary files Classes for writing binary files
Background image of page 4
COMP201 Topic 6 / Slide 5 Reader All classes for reading from text files descend from the abstract class Reader Reader has an method read , which returns the next unicode character or –1 (EOF) Reader LineNumber Reader Pushback Reader InputStream Reader CharArray Reader Filter Reader Buffered Reader String Reader Piped Reader File Reader
Background image of page 5

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

View Full DocumentRight Arrow Icon
COMP201 Topic 6 / Slide 6 Writer All classes for writing to text files descend from the abstract class Writer Writer has an method write(int b ) , which writes a unicode character to an output Writer Print Writer File Writer Buffered Writer OutputStream Writer Piped Writer Filter Writer CharArray Writer String Writer
Background image of page 6
COMP201 Topic 6 / Slide 7 InputStream All classes for reading from binary files descend from the abstract class InputStream InputStream has one abstract method read , which returns the next byte character or –1 (EOF) InputStream Pushback InputStream LineNumber InputStream Data InputStream Buffered InputStream File InputStream ByteArray InputStream Filter InputStream Sequence InputStream StringBuffer InputStream Object InputStream Piped InputStream . . . .
Background image of page 7

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

View Full DocumentRight Arrow Icon
OutputStream All classes for writing to binary files descend from abstract class OutputStream OutputStream has one abstract method write ( int b) , which writes one byte to an output OutputStream Checked OutputStream PrintStream Data OutputStream Buffered OutputStream ByteArray OutputStream Filter OutputStream Object OutputStream Piped OutputStream . . . . File
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/14/2010 for the course COMP COMP 201 taught by Professor Nil during the Spring '02 term at HKUST.

Page1 / 30

lec6 - COMP201 Java Programming Topic 6: Streams and Files...

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

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