zoukankan      html  css  js  c++  java
  • java中输出hex bytes

    在java里输出bytes array乍一想好像不难,但是做起来还是小有点学问,没想到也有个printf的方法,挺好用的,不废话看代码:

    public class Test {

        
    /**
         * 
    @param args
         
    */
        
    public static void main(String[] args) {
            
    // TODO Auto-generated method stub
            byte[] buffer = new byte[] 
             {
                    (
    byte)0x00, (byte)0xFE, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00
                    (
    byte)0x01, (byte)0xCC, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00
                    (
    byte)0x02, (byte)0x25, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00
             };
            
            
    for (int i = 0; i < buffer.length; i ++) {
                System.out.printf(
    "0x%02X ", buffer[i]);
            }
        }

    }


  • 相关阅读:
    NOIP2018 模拟赛(二十二)雅礼NOI
    浅谈左偏树在OI中的应用
    HDU3062&&HDU1814
    2-SAT超入门讲解
    bitset常用用法&&简单题分析
    NOIp2014提高组初赛错题简析
    2018十月刷题列表
    BZOJ 4804: 欧拉心算
    Luogu P2568 GCD
    Luogu P4137 Rmq Problem / mex
  • 原文地址:https://www.cnblogs.com/luoluo/p/769609.html
Copyright © 2011-2022 走看看