package com.walker.openocr.util; import org.apache.commons.codec.binary.Base64; import org.springframework.util.FileCopyUtils; import java.io.File; import java.io.IOException; /** * 描述: * @author 时克英 * @date 2020年2月18日 下午10:06:57 */ public class FaceUtils { public static final String getImageBase64(String filePath){ byte[] fileBytes; try { fileBytes = FileCopyUtils.copyToByteArray(new File(filePath)); byte[] fileBase64 = Base64.encodeBase64(fileBytes); return new String(fileBase64); } catch (IOException e) { e.printStackTrace(); return null; } } }