日期:2014-05-20 浏览次数:20753 次
import java.io.*; public class TestDateStream { public static void main(String[] args) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); //DateOutputStream dos = new DateOutputStream(baos); DataOutputStream dos = new DataOutputStream(baos); try { // baos.writeDouble(Math.random()); // baos.writeBoolean(true); dos.writeDouble(Math.random()); dos.writeBoolean(true); //ByteArrayInputStream bais = new ByteArrayInoutStream( ByteArrayInputStream bais = new ByteArrayInputStream( baos.toByteArray()); System.out.println(bais.available()); //DateInputStream dis = new DateInputStream(bais); DataInputStream dis = new DataInputStream(bais); System.out.println(dis.readDouble()); System.out.println(dis.readBoolean()); dos.close(); dis.close(); } catch (IOException e) { e.printStackTrace(); } } }