关于在Idea调试的时如何显示16进制的处理

关于在Idea调试的时如何显示16进制的处理

右击字节数组,然后选择“View as”,再选择“Create”

 

关于在Idea调试的时如何显示16进制的处理

添加对byte[]的处理,给个名称,并给个表达式,处理表达式如下:

int len = this.length;

StringBuilder sb = new StringBuilder(len * 2);

for (int i = 0; i < len; i++) {

    byte b = this[i];

    String str = Integer.toHexString(b);

    if (str.length() == 1) {

        sb.append("0").append(str).append(" ");

    } else if (str.length() > 2) {

        sb.append(str.substring(str.length() - 2)).append(" ");

    } else {

        sb.append(str).append(" ");

    }

}

return sb.toString().toUpperCase();

关于在Idea调试的时如何显示16进制的处理

 

填写完成后点击“Apply”和“ok”,返回。

关于在Idea调试的时如何显示16进制的处理

再次右击,选择“View as”中刚才建立的处理表达式。

 

对于字节的显示做同样的处理,只不达表达式换为另一个表达式:

关于在Idea调试的时如何显示16进制的处理

关于在Idea调试的时如何显示16进制的处理

java.lang.String hex = java.lang.Integer.toHexString(this&0xFF);
if
(hex.length()<=1) {
    hex =
"0"+hex;
}
return "0x"+hex.toUpperCase() +" ["+this+"]";

关于在Idea调试的时如何显示16进制的处理

相关文章:

  • 2022-12-23
  • 2021-05-17
  • 2021-10-14
  • 2021-07-13
  • 2021-12-28
猜你喜欢
  • 2022-12-23
  • 2022-01-21
  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
  • 2021-07-10
  • 2021-10-12
相关资源
相似解决方案