1 / 3

Chapter 8: Understanding Streams

Chapter 8: Understanding Streams. Understanding Streams. JDK 1.4 introduce a new way of handling primitive data types defined in java.nio & java.nio.channels packages A stream is a sequence of bytes The main reason for using streams is to make your program independent of the device involved

kyra-boone
Download Presentation

Chapter 8: Understanding Streams

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 8: Understanding Streams

  2. Understanding Streams • JDK 1.4 introduce a new way of handling primitive data types defined in java.nio & java.nio.channels packages • A stream is a sequence of bytes • The main reason for using streams is to make your program independent of the device involved • Two types • Binary • Character • The package java.io contains two main classes InputStream and OutputStream • InputStream has seven direct classes (Audio, File, Object, Sequence, ByteArray, Pipelined, Filter) • The FilterInputStream has further nine direct classes. One of them is BufferedInputStream (for efficient I/O)

  3. Understanding Streams (cont.) • OutputStream has five direct classes (File, Object, ByteArray, Piped, Filter). • Stream readers and Writers are objects that can read and write byte streams as character streams • Reader has sic derived classes (InputSteam, Buffered, Filter, Piped, CharArray, String) • Ex: BufferedReader keyboard = new BufferedReader (new InputStreamReader(System.in)) • Getting data from the keyboard using the StreamTokenizer class • Methods suck as nextToken() returns int value and it can be TT_NUMBER, TT_WORD, TT_EOF, TT_EOL • Ex: FormatedInput.java & TestFormattedInput.java • Ex: FormattedWriter & TestedFormattedWriter

More Related