UNB/ CS/ David Bremner/ teaching/ java/ DataStreamTest.java
import java.io.IOException;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.io.DataInputStream;
public class DataStreamTest{
    public static void writeIt() throws IOException{
        byte [] data={ 0, 74, 0, 65, 0, 86, 0, 65 };
        FileOutputStream out= new FileOutputStream("mystery.dat");
        for (int i=0; i<data.length; i++)
            out.write(data[i]);
        out.close();
    }
    public static void main(String [] args) throws IOException{

        writeIt();

        DataInputStream input; 

        input=new DataInputStream(new FileInputStream("mystery.dat"));
        System.out.println(input.readLong());

        input=new DataInputStream(new FileInputStream("mystery.dat"));
        System.out.println(input.readInt()+" "+input.readInt());

        input=new DataInputStream(new FileInputStream("mystery.dat"));
        for (int i=0; i<4; i++)
            System.out.print(input.readShort()+" ");
        System.out.println("");

        input=new DataInputStream(new FileInputStream("mystery.dat"));
        System.out.println(input.readFloat()+" "+input.readFloat());

        input=new DataInputStream(new FileInputStream("mystery.dat"));
        System.out.println(input.readDouble());

        input=new DataInputStream(new FileInputStream("mystery.dat"));
        for (int i=0; i<4; i++)
            System.out.print(input.readChar());
        System.out.println("");
        

    }

        
        
        
}
//