tailieunhanh - Introduction to java programming: Chapter 18 - Binary I/O

Introduction to java programming: Chapter 18 - Binary I/O's Objectives is to understand how I/O is processed in Java; distinguish between text I/O and binary I/O; read and write bytes using FileInputStream and FileOutputStream; read and write primitive values and strings using DataInputStream/DataOutputStream. | Chapter 18 Binary I O Chapter 9 Inheritance and Polymorphism Chapter 17 Exceptions and Assertions T Chapter 18 Binary I O Chapter 6 Arrays Chapter 19 Recursion Liang Introduction to Java Programming Sixth Edition c 2005 Pearson Education Inc. All rights reserved. 0-13-148952-6 Objectives To understand how I O is processed in Java . To distinguish between text I O and binary I O . To read and write bytes using FileInputStream and FileOutputStream . To read and write primitive values and strings using DataInputStream DataOutputStream . To store and restore objects using ObjectOutputStream and ObjectInputStream and to understand how objects are serialized and what kind of objects can be serialized . To use the Serializable interface to enable objects to be serializable . To know how to serialize arrays . To use RandomAccessFile for both read and write Optional . Liang Introduction to Java Programming Sixth Edition c 2005 Pearson Education Inc. All rights reserved. 0-13-148952-6 How is I O Handled in Java A File object encapsulates the properties of a file or a path but does not contain the methods for reading writing data from to a file. In order to perform I O you need to create objects using appropriate Java I O classes. Scanner input new Scanner new File Program Input object created from an input class Input stream Output object reẾted from an output class Output stream Formatter output new Formatter s Java 101 Liang Introduction to Java Programming Sixth Edition c 2005 Pearson Education Inc. All rights reserved. 0-13-148952-6