//每32个字节换行打印 public static void formatPrint(String hexStr){ int no = 0; int length = hexStr.length(); for (int i=0;i<length;i++){ if ((i+1)%32==0){ String s = twoSpaceTwo(hexStr.substring(i - 31, i + 1));
System.out.println("no"+no+":"+s); no++; if (length-i<32){
return; } } } }
//隔两位打印一个空格----正则表达式方法 public static String twoSpaceTwo(String replace){ String regex = "(.{2})"; replace = replace.replaceAll(regex, "$1 "); return replace; }
标签:十六进制,String,no,换行,32,replace,int,length From: https://www.cnblogs.com/stono/p/18146649