• 二进制数据读写


    public static void binWriteTest() {
            int _int = 12345678;
            ByteBuffer _nbuffer = ByteBuffer.allocate(4);
            _nbuffer.order(ByteOrder.nativeOrder()); // 将新建的ByteBuffer设置为本机的字节顺
            _nbuffer.putInt(_int);
            _nbuffer.flip();
    
            try {
                FileOutputStream _fou = new FileOutputStream("test_dout.data");
                FileOutputStream _nfou = new FileOutputStream("test_nbuf.data");
                DataOutputStream _dou = new DataOutputStream(_fou);
    
                _dou.writeInt(_int);
                _dou.close();
    
                _nfou.write(_nbuffer.array());
                _nfou.close();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    
            System.out.println(ByteOrder.nativeOrder());
    
            _int = 789;
            String strteString = "abcdefghi>-1245:";
            float fval = 1234567.11f;
            try {
                FileOutputStream _nfou = new FileOutputStream(
                        Constant.DATADIR_STRING + "test_nbuf.data");
                DataOutputStream _dou = new DataOutputStream(_nfou);
                _dou.writeInt(_int);
                _dou.writeFloat(fval);
                _dou.writeUTF(strteString);
                ;
                _dou.close();
                FileInputStream _nfin = new FileInputStream(Constant.DATADIR_STRING
                        + "test_nbuf.data");
                DataInputStream _din = new DataInputStream(_nfin);
    
                _int = _din.readInt();
                fval = _din.readFloat();
                strteString = _din.readUTF();
    
                _din.close();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
  • 相关阅读:
    邮件发送的原理
    链接
    VS2010安装EntityFramework5.0
    asp.net mvc 使用Ajax
    图解WPF程序打包全过程
    MapReduce,DataJoin,链接多数据源
    Hadoop,MapReduce操作Mysql
    MapReduce,组合式,迭代式,链式
    下一代hadoop(Mapreduce),YARN/MRv2
    HBase 简介
  • 原文地址:https://www.cnblogs.com/profession/p/3663297.html
Copyright © 2020-2023  润新知