zoukankan      html  css  js  c++  java
  • 【操作基本数据类型的流】

    package test;
    
    import java.io.*;
    
    /**
     * @author shusheng
     * @description 操作基本数据类型的流
     * @Email shusheng@yiji.com
     * @date 2018/12/23 0:08
     */
    public class DataStreamDemo {
        public static void main(String[] args) throws IOException {
            write();
            read();
        }
    
        public static void write() throws IOException {
            //创建输出流对象
            DataOutputStream dos = new DataOutputStream(new FileOutputStream("dos.txt"));
    
            //写数据
            dos.writeByte(10);
            dos.writeBoolean(true);
            dos.writeChar('A');
            dos.writeDouble(1101101.1011110);
            dos.writeFloat((float) 1.023);
            dos.writeShort(123);
            dos.close();
        }
    
        public static void read() throws IOException {
            //创建数据输入流对象
            DataInputStream dis = new DataInputStream(new FileInputStream("dos.txt"));
            byte b = dis.readByte();
            boolean a = dis.readBoolean();
            char c = dis.readChar();
            double d = dis.readDouble();
            float f = dis.readFloat();
            short s = dis.readShort();
            dis.close();
    
            System.out.println(a);
            System.out.println(b);
            System.out.println(c);
            System.out.println(d);
            System.out.println(f);
            System.out.println(s);
    
        }
    }
    终身学习者
  • 相关阅读:
    docker容器,镜像常用操作
    微信小程序登录状态
    微信小程序登录流程图
    GET和POST可传递的值到底有多大?
    php发送请求
    thinkphp 导入微信小程序加密解密库
    thinkphp 随机获取一条数据
    bootstrap row 行间距
    webstorm es6 语法报错
    Laravel
  • 原文地址:https://www.cnblogs.com/zuixinxian/p/10340667.html
Copyright © 2011-2022 走看看