Write integers using DataOutputStream in Java
Description
The following code shows how to write integers using DataOutputStream.
Example
// w w w. jav a 2 s.c o m
import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(
new File("temp.tmp"))));
for (int i = 0; i < 10; i++)
dos.writeInt(i);
dos.close();
}
}