How to Declare a DataOutputStream

DataOutputStream was added in API Level 1

Wraps an existing OutputStream and writes big-endian typed data to it. Typically, this stream can be read in by DataInputStream. Types that can be written include byte, 16-bit short, 32-bit int, 32-bit float, 64-bit long, 64-bit double, byte strings, and MUTF-8 encoded strings.

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

import java.io.DataOutputStream;

2. In the onCreate method, add the below line to declare a new DataOutputStream named myDataOutputStream.

DataOutputStream myDataOutputStream;