类 Base64Utils

java.lang.Object
com.walker.infrastructure.utils.Base64Utils

public class Base64Utils extends Object

BASE64编码解码工具包

依赖javabase64-1.3.1.jar

版本:
1.0
作者:
IceWee
  • 构造器详细资料

    • Base64Utils

      public Base64Utils()
  • 方法详细资料

    • decode

      public static byte[] decode(String base64) throws Exception

      BASE64字符串解码为二进制数据

      参数:
      base64 -
      返回:
      抛出:
      Exception
    • encode

      public static String encode(byte[] bytes) throws Exception

      二进制数据编码为BASE64字符串

      参数:
      bytes -
      返回:
      抛出:
      Exception
    • encodeFile

      public static String encodeFile(String filePath) throws Exception

      将文件编码为BASE64字符串

      大文件慎用,可能会导致内存溢出

      参数:
      filePath - 文件绝对路径
      返回:
      抛出:
      Exception
    • decodeToFile

      public static void decodeToFile(String filePath, String base64) throws Exception

      BASE64字符串转回文件

      参数:
      filePath - 文件绝对路径
      base64 - 编码字符串
      抛出:
      Exception
    • fileToByte

      public static byte[] fileToByte(String filePath) throws Exception

      文件转换为二进制数组

      参数:
      filePath - 文件路径
      返回:
      抛出:
      Exception
    • byteArrayToFile

      public static void byteArrayToFile(byte[] bytes, String filePath) throws Exception

      二进制数据写文件

      参数:
      bytes - 二进制数据
      filePath - 文件生成目录
      抛出:
      Exception