package com.dy.testClient.httpCl; import java.io.UnsupportedEncodingException; import java.util.Base64; import com.dy.common.util.ByteUtil; public class TestBase64 { public static void main(String[] args) throws UnsupportedEncodingException{ String hex1 = "6838363235393230353934333439373000002002303231310000000000000032003005002E000000000001000000000200000000032101010012330400300521010100123306016907016908000009FF0000FC16" ; System.out.println(hex1); byte[] bs = ByteUtil.hex2Bytes(hex1) ; bs = Base64.getEncoder().encode(bs) ; String base64 = new String(bs, "UTF-8") ; System.out.println(base64); bs = Base64.getDecoder().decode(base64); String hex2 = ByteUtil.bytes2Hex(bs, false) ; System.out.println(hex2); } }