integrated_traffic/src/main/java/com/zcloud/util/Base64Util.java

18 lines
487 B
Java
Raw Normal View History

2024-03-06 16:25:53 +08:00
package com.zcloud.util;
import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Encoder;
import java.io.IOException;
public class Base64Util {
public static String getBase64String(MultipartFile multiPartFile) throws IOException {
String baseStr = null;
BASE64Encoder encoder = new BASE64Encoder();
baseStr = encoder.encode(multiPartFile.getBytes());
baseStr = baseStr.replaceAll("\r\n", "");
return baseStr;
}
}