DataInputStream Class

Package: java.io

This class reads primitive data types, such as integers and doubles, directly from an input stream. It is the class you’ll use most often to read data from a binary file.

CrossRef.eps The DataInputStream class is one of many Java I/O classes that use streams. For more information, see Streams (Overview).

Constructor

Constructor

Description

DataInputStream (InputStream in)

Creates a data input stream from any object that extends the InputStream class. Typically, you pass this constructor a BufferedInputStream object.

Methods

Method

Description

boolean readBoolean()

Reads a boolean value from the input stream. It throws EOFException and IOException.

byte readByte()

Reads a byte value from the input stream. It throws EOFException and IOException.

char readChar()

Reads a char value from the input stream. It throws EOFException and IOException.

double readDouble()

Reads a double value from the input stream. It throws EOFException and IOException.

float readFloat()

Reads a float value from the input stream. It throws EOFException and IOException.

int readInt()

Reads an int value from the input stream. It throws EOFException and IOException.

long readLong()

Reads a long value from the input stream. It throws EOFException and IOException.

short readShort()

Reads a short value from ...

Get Java For Dummies Quick Reference now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.