方法一:

用java自带的方法

先将字符串转为字符数组,然后用Integer.toHexString方法进行转换。

缺点:中文容易乱码

 

方法二:

使用apache的包codec中的方法

org.apache.commons.codec.binary.Hex#encodeHexString(byte[])

按字节高四位低四位转换,支持各种编码。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
  • 2021-11-25
  • 2021-11-16
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2021-08-20
  • 2022-12-23
  • 2021-09-16
  • 2021-10-17
相关资源
相似解决方案