zoukankan      html  css  js  c++  java
  • DataInputStream数据字节专属输入流

    DataInputStream:数据字节输入流。
    DataOutputStream写的文件,只能用DataInputStream去读。并且读的时候你需要提前知道写入的顺序。
    读的顺序需要和写的顺序一致。才可以正常取出数据。
     
     
    DataInputStream:
    package com.javaSe.DataInputStream;
    
    
    import java.io.DataInputStream;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    
    
    /*
    DataInputStream:数据字节输入流。
    DataOutputStream写的文件,只能用DataInputStream去读。并且读的时候你需要提前知道写入的顺序。
    读的顺序需要和写的顺序一致。才可以正常取出数据。
    */
    public class DataInputStreamTest01 {
        public static void main(String[] args) {
            DataInputStream ds = null;
        
            try {
                ds = new DataInputStream(new FileInputStream("data"));
                byte b = ds.readByte();
                short s = ds.readShort();
                int i = ds.readInt();
                long l = ds.readLong();
                float f = ds.readFloat();
                double d = ds.readDouble();
                boolean bl = ds.readBoolean();
                char c = ds.readChar();
        
                System.out.println(b);
                System.out.println(s);
                System.out.println(i);
                System.out.println(l);
                System.out.println(f);
                System.out.println(d);
                System.out.println(bl);
                System.out.println(c);
                
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                if (ds != null) {
                    try {
                        ds.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
  • 相关阅读:
    Myeclipse安装svn插件
    Hudson+Maven+Svn搭建持续集成环境
    svn merge和branch分析
    Linux下安装subversion1.6.5和apache2
    C语言中,为什么字符串可以赋值给字符指针变量
    Loadrunner C 编程_1
    oracle解决多表关联分组查询问题
    学习英语
    使用 JMeter 完成常用的压力测试 [转]
    Jmeter零起点学习
  • 原文地址:https://www.cnblogs.com/xlwu/p/13466139.html
Copyright © 2011-2022 走看看