How to Declare a DataInputStream

DataInputStream was added in API Level 1
Wraps an existing InputStream and reads big-endian typed data from it. Typically, this stream has been written by a DataOutputStream. Types that can be read include byte, 16-bit short, 32-bit int, 32-bit float, 64-bit long, 64-bit double, byte strings, and strings encoded in modified UTF-8.

1. In the file, add the below import to the imports section.


2. In the onCreate method, add the below line to declare a new DataInputStream named myDataInputStream.

DataInputStream myDataInputStream;

3. Compile and run!

Next Recommended Article: How to Initialize a DataInputStream