java图片转base64(不换行)
public static String ImageToBase64(String imgPath) {
InputStream in = null;
byte[] data = null;
// 读取图片字节数组
try {
in = new FileInputStream(imgPath);
data = new byte[in.available()];
in.read(data);
in.close();
} catch (IOException e) {
e.printStackTrace();
}
String base64String = Base64.encodeBase64String(data);
System.out.println(base64String);