在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]);
        }
    }

}


相关文章:

  • 2021-05-26
  • 2021-05-24
  • 2021-11-01
  • 2022-12-23
  • 2021-08-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-06
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-08
相关资源
相似解决方案