package edu.exam14.ex06data_buffer;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class DataBufferFilterStream {
public static void main(String[] args) throws IOException {
// user -> dOut -> bOut -> out ->MyData.bin
OutputStream out = new FileOutputStream("MyData.bin");
BufferedOutputStream bOut = new BufferedOutputStream(out);
DataOutputStream dOut = new DataOutputStream(bOut);
dOut.writeInt(9999);
dOut.writeDouble(1.125);
dOut.writeChars("aaa");
dOut.close();
// 읽어보자
InputStream in = new FileInputStream("MyData.bin");
BufferedInputStream bIn = new BufferedInputStream(in);
DataInputStream dIn = new DataInputStream(bIn);
int num = dIn.readInt();
double dNum = dIn.readDouble();
byte[] bStr = new byte[100];
dIn.read(bStr);
String str = bStr.toString();
dIn.close();
System.out.println(num);
System.out.println(dNum);
System.out.println(str);
}
}