Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java Input / Output l a modular approach to input/output: - different stream objects are connected/wrapped to handle I/O l a data stream object: a flow.

Similar presentations


Presentation on theme: "Java Input / Output l a modular approach to input/output: - different stream objects are connected/wrapped to handle I/O l a data stream object: a flow."— Presentation transcript:

1 Java Input / Output l a modular approach to input/output: - different stream objects are connected/wrapped to handle I/O l a data stream object: a flow of data l an input stream: an object used for reading data l an output stream: an object used for writing data Example: ConsoleApp.java

2 Java Input / Output l two class hierarchies… l byte stream objects (8 bit bytes) Java abstract classes: InputStream, OutputStream l character/textual stream objects 16 bit UTF-16 characters Java abstract classes: Reader, Writer

3 Week 11: Java Input / Output three predefined byte streams - System.in ( InputStream object ) - System.out ( PrintStream object ) - System.err ( PrintStream object ) PrintStream: an OutputStream object that contains print() and println()

4 The API for Java Input/Output l functional categories of I/O classes l data sink streams: objects that read from and write to data “sinks” (i.e. sources and destinations) l processing streams: objects that process the data (e.g. data conversion, buffering) l processing streams offer efficient reading, writing and functionality

5 The API for Java Input/Output InputStream OutputStreamReaderWriter data sink streams FileInputStream FileOutputStreamFileReaderFileWriter processing streams BufferedInputStream BufferedOutputStream ObjectInputStream ObjectOutputStream InputStreamReader ———————  BufferedReader OutputStreamWriter ——-——  BufferedWriter

6 Examples of Java I/O Applications keyboard input: ConsoleApp.java - use of a byte stream and character streams file I/O - byte streams: FileStreams.java - character streams: FileReaderWriter.java - formatted data and byte stream: DataIOTest.java

7 Java I/O Applications l use of Properties file externalize connection parameters DBConnectionFile.java l use of text file to store SQL CreateDBFile.java


Download ppt "Java Input / Output l a modular approach to input/output: - different stream objects are connected/wrapped to handle I/O l a data stream object: a flow."

Similar presentations


Ads by Google