Java: A Beginner's Guide, Sixth Edition: A Beginner's Guide by Herbert Schildt

Java: A Beginner's Guide, Sixth Edition: A Beginner's Guide by Herbert Schildt

Author:Herbert Schildt [Schildt, Herbert]
Language: eng
Format: epub, mobi
Tags: -
Publisher: McGraw-Hill Education
Published: 2014-04-14T21:00:00+00:00


Reading and Writing Binary Data

So far, we have just been reading and writing bytes containing ASCII characters, but it is possible—indeed, common—to read and write other types of data. For example, you might want to create a file that contains ints, doubles, or shorts. To read and write binary values of the Java primitive types, you will use DataInputStream and DataOutputStream.

DataOutputStream implements the DataOutput interface. This interface defines methods that write all of Java’s primitive types to a file. It is important to understand that this data is written using its internal, binary format, not its human-readable text form. Several commonly used output methods for Java’s primitive types are shown in Table 10-5. Each throws an IOException on failure.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.