Object-Oriented Programming with Java Lecture Notes

18 March 2008 • Stream I-O


Outline

  • I-O varities.

  • Binary Stream I-O.

  • Text Readers and Writers.

    • Reader parsing.

  • Linking Text and Binary I-O.

helvetica

Binary vs. Formatted I-O

3-Axis I-O

Abstract Input and Output

Output Streams

void close()

void flush()

abstract void write(int b)

void write(byte [] b)

void write(byte [] b, int off, int len)

Input Streams

int available()

void close()

long skip(long n)

Reading Input Streams

abstract int read()

int read(byte [] b)

int read(byte [] b, int off, int len)

Marking Input Streams

Less Abstract I-O Streams

Input-Stream Classes

Output-Stream Classes

Stream Capabilities

Filter Streams

Input Filters

Input-Filter Example

import javax.crypto.CipherInputStream;
import javax.crypto.Cipher;
import java.io.InputStream;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

void seekritRead(String filename, Cipher cipher) 
throws FileNotFoundException, IOException {

  final InputStream inputStream =
      new CipherInputStream(
	new BufferedInputStream(
	  new FileInputStream(filename)),
	cipher);

  // blah blah blah

  inputStream.close();
  }

Output Filters

I-O Stream Summary

Data I-O

Data I-O

Data I-O streams

Human-Oriented I-O

Abstract Readers and Writers

Writers

Writer Sinks

Readers

Reader Sources

Formatted Translation

The Scanner

Character Sets

Reader-Writer Summary

I-O Exceptions

Summary

Credits


This page last modified on 4 March 2008.

Creative
    Commons License