1 / 7

Java Input / Output

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

Download Presentation

Java Input / Output

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. Java Input / Output • a modular approach to input/output: - different stream objects are connected/wrapped to handle I/O • a data stream object: a flow of data • an input stream: an object used for reading data • an output stream: an object used for writing data • Example: ConsoleApp.java

  2. Java Input / Output • two class hierarchies… • byte stream objects (8 bit bytes) • Java abstract classes: InputStream, OutputStream • character/textual stream objects16 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 • functional categories of I/O classes • data sink streams: objects that read from and write to data “sinks” (i.e. sources and destinations) • processing streams: objects that process the data (e.g. data conversion, buffering) • processing streams offer efficient reading, writing and functionality

  5. The API for Java Input/Output InputStream OutputStream Reader Writer data sink streams FileInputStream FileOutputStream FileReader FileWriter 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 • use of Properties file • externalize connection parameters • DBConnectionFile.java • use of text file to store SQL • CreateDBFile.java

More Related