标签:
1 import java.io.*; 2 public class TestDataStream { 3 public static void main(String[] args) { 4 ByteArrayOutputStream baos = 5 new ByteArrayOutputStream(); 6 DataOutputStream dos = 7 new DataOutputStream(baos); 8 try { 9 dos.writeDouble(Math.random()); 10 dos.writeBoolean(true); 11 ByteArrayInputStream bais = 12 new ByteArrayInputStream(baos.toByteArray()); 13 System.out.println(bais.available()); 14 DataInputStream dis = new DataInputStream(bais); 15 System.out.println(dis.readDouble()); 16 System.out.println(dis.readBoolean()); 17 dos.close(); dis.close(); 18 } catch (IOException e) { 19 e.printStackTrace(); 20 } 21 } 22 }
标签:
原文地址:http://www.cnblogs.com/roger-h/p/4493443.html