字节码与16进制字符串相互转换
来源:互联网 发布:pkpm脚手架计算软件 编辑:程序博客网 时间:2024/05/20 17:08
//字节码转换成16进制字符串
public static String byte2hex(byte[] b) {
String hs="";
String stmp="";
for (int n=0;n<b.length;n++){
stmp=(java.lang.Integer.toHexString(b[n] & 0XFF));
if (stmp.length()==1)
hs=hs+"0"+stmp;
else hs=hs+stmp;
//if (n<b.length-1) hs=hs+":";
}
return hs.toUpperCase();
}
//16进制字符串转换成字节码
public static byte[] hex2byte(String h) {
byte[] ret = new byte[h.length()/2];
for(int i=0; i<ret.length; i++){
ret[i] = Integer.decode("#"+h.substring(2*i, 2*i+2)).byteValue();
}
return ret;
}
public static String byte2hex(byte[] b) {
String hs="";
String stmp="";
for (int n=0;n<b.length;n++){
stmp=(java.lang.Integer.toHexString(b[n] & 0XFF));
if (stmp.length()==1)
hs=hs+"0"+stmp;
else hs=hs+stmp;
//if (n<b.length-1) hs=hs+":";
}
return hs.toUpperCase();
}
//16进制字符串转换成字节码
public static byte[] hex2byte(String h) {
byte[] ret = new byte[h.length()/2];
for(int i=0; i<ret.length; i++){
ret[i] = Integer.decode("#"+h.substring(2*i, 2*i+2)).byteValue();
}
return ret;
}
- 字节码与16进制字符串相互转换
- 16进制字符串与字节数组相互转换
- 字符串与字节码的相互转换
- 字符串与字节数组相互转换
- C# 字符串与字节数组相互转换
- 字节码与十六进制字符相互转换
- PHP 字符串与16进制相互转换
- 关于字符串与字节byte之前的相互转换问题
- C#下字符串与字节数组之间的相互转换
- 多字节与宽字节字符串的相互转换
- 字节数组与十六进制字符串之间的相互转换
- C#字节数组与字符串相互转换代码案例
- 多字节与宽字节字符串 的相互转换
- C#字节数组与字符串相互转换代码案例
- 字节数组与16进制字符串之间的转换
- 16进制与字符串、字节数组之间的转换
- 字节数据与十六进制的相互转换,字符串与十六进制的相互转换
- 字节数组byte[]与16进制字符串的相互转化
- 扩展Eclipse Pespectives时,设置自己Pesptective的布局
- Spring的依赖关系
- 关于汇编的一些指令
- SQL Server检测是不是数字类型的函数(非ISNUMERIC)
- 傲游(Maxthon)假死问题-小一博客
- 字节码与16进制字符串相互转换
- setCapture和releaseCapture的小应用
- WinCE5.0 Socket UDP Multicast例子
- dll动态链接库制作方法
- jbuilder 2006中,log4j 的加载
- 遭遇RootKit.Win32.GameHack.GEN,Trojan.PSW.Win32.GameOL.GEN,RootKit.Win32.Mnless等2
- 粗心
- 远程协助器V2.0
- .NET平台下可复用的Tcp通信层实现