package com.givenera.appapi.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
public class ImageBase64 {
public static void main(String[] args)
{
String strImg = GetImageStr(System.getProperty("user.dir") +"/data/scrFile666.jpg");
System.out.println(strImg);
GenerateImage(strImg, "C:/Users/58/Desktop/scrFileffff.jpg");
}
/*
* 图片转化成base64字符串
* imagefilePath 图片路径
*/
public static String GetImageStr(String imagefilePath)
{//将图片文件转化为字节数组字符串,并对其进行Base64编码处理
InputStream in = null;
byte[] data = null;
//读取图片字节数组
try
{
in = new FileInputStream(imagefilePath);
data = new byte[in.available()];
in.read(data);
}
catch (IOException e)
java图片编码base64以及base64转换为图片代码
最新推荐文章于 2024-05-16 22:03:22 发布