Base64处理byte[ ]和base64字符串之间的转换
1、工具类
2、普通String和byte[]转换
3、在线转换工具
http://www.vgot.net/test/image2base64.php?
import org.apache.commons.codec.binary.Base64; public class UtilHelper { //base64字符串转byte[] public static byte[] base64String2ByteFun(String base64Str){ return Base64.decodeBase64(base64Str); } //byte[]转base64 public static String byte2Base64StringFun(byte[] b){ return Base64.encodeBase64String(b); } }
2、普通String和byte[]转换
public static void main(String[] args) { String str="我是中国人"; byte[] arr=str.getBytes(); System.out.println("打印:"+arr); String str2=new String(arr); System.out.println("打印2:"+str2); }
3、在线转换工具
http://www.vgot.net/test/image2base64.php?
声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇: SQL获取最新一笔数据的两个查询方法
- 下一篇: JS判断输入中是否包含中文字符