cool hit counter DataIO&ByteArrayIo_Intefrankly

DataIO&ByteArrayIo


  • DataInputStream and DataOutputStream inherit from InputStream and OutputStream respectively, which are processing streams and need to be "snapped" onto node streams of type InputStream and OutputStream respectively
  • DataInputStream and DataOutputStream provide methods that allow access to machine-independent Java raw type data
  • The constructors of DataInputStream and DataOutputStream are.
    • DataInputStream(InputStream in)
    • DataOutputStream(OutputStream out)
import java.io.*;

public class TestFileInputStream {

    public static void main(String[] args) {
        ByteArrayOutputStream baos = 
                new ByteArrayOutputStream();
        DataOutputStream dos = 
                new DataOutputStream(baos);
        try {
            dos.writeDouble(Math.random());
            dos.writeBoolean(true);
            ByteArrayInputStream bais = 
                    new ByteArrayInputStream(baos.toByteArray());
            System.out.println(bais.available());//baisHow many bytes are in
            DataInputStream dis = 
                    new DataInputStream(bais);
            System.out.println(dis.readDouble());// First to write reads first
            System.out.println(dis.readBoolean());
            dos.close();
            dis.close();
        }catch(IOException e) {
            e.printStackTrace();
        }
    }
}

A diagram is given below to help understand


Recommended>>
1、Happy fried gold flower external hang cheat universal version the original various seethrough happy fried gold flower auxiliary software
2、Pouring it on learning methods for statisticsdata analysis
3、Nchain awarded three digital rights management patents with blockchain technology
4、Why are there so many more blockchain apps overnight Can the Chinese be a little innovative
5、Bottos for your data security in the age of big data

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号