标签:void OLE read tput print rac java io exception pre
http://www.verejava.com/?id=16994693533915
package com.io2;
import java.io.*;
public class TestByteArrayInputStream
{
public static void main(String[] args)
{
try
{
//向文件中 以 int ,double,boolean ,String 存入数据
//字节数组内存流
ByteArrayOutputStream baos=new ByteArrayOutputStream();
DataOutputStream dos=new DataOutputStream(baos);
dos.writeUTF("张三");
dos.writeInt(20);
dos.writeBoolean(true);
dos.writeDouble(10.2);
//取得数据
ByteArrayInputStream bais=new ByteArrayInputStream(baos.toByteArray());
DataInputStream dis=new DataInputStream(bais);
//注意 取数据 的顺序 必须和存数据的一样
System.out.println(dis.readUTF());
System.out.println(dis.readInt());
System.out.println(dis.readBoolean());
System.out.println(dis.readDouble());
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
http://www.verejava.com/?id=16994693533915
Java IO ByteArrayInputStream DataOutputStream
标签:void OLE read tput print rac java io exception pre
原文地址:https://www.cnblogs.com/verejava/p/9227217.html