java 图片与base64相互转化

 

CreateTime--2017年12月4日17:38:44

Author:Marydon

需要导入:

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.UUID;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
/**
 * 图片转base64字符串
 * @param path
 * @return
 */
public static String PictoBase64(String path) {
    InputStream in = null;
    byte[] data = null;
    // 读取图片字节数组
    try {
        in = new FileInputStream(path);
        data = new byte[in.available()];
        in.read(data);
        in.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    // 对字节数组Base64编码
    BASE64Encoder encoder = new BASE64Encoder();
    return encoder.encode(data);// 返回Base64编码过的字节数组字符串
}

/**
 * base64写图片
 * @param imgStr
 * @return
 */
public static boolean Base64toPic(String imgStr) {

    // 对字节数组字符串进行Base64解码并生成图片
    if (imgStr == null) // 图像数据为空
        return false;
    BASE64Decoder decoder = new BASE64Decoder();
    try {
        // Base64解码
        byte[] b = decoder.decodeBuffer(imgStr);
        for (int i = 0; i < b.length; ++i) {
            if (b[i] < 0) {// 调整异常数据
                b[i] += 256;
            }
        }
        String imgName = UUID.randomUUID().toString().replace("-", "");
        String imgType = ".png";
        // 生成png图片
        String imgFilePath = "C:/Users/Administrator/Desktop/" + imgName + imgType;// 新生成的图片
        OutputStream out = new FileOutputStream(imgFilePath);
        out.write(b);
        out.flush();
        out.close();
        return true;
    } catch (Exception e) {
        return false;
    }
}

测试:

public static void main(String[] args) {//data:image/jpeg;base64,
    // base64转图片
    String str = "/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wgARCAFNAPMDASIAAhEBAxEB/8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OVzZz7FPo4md3WJT1EXN5VU8TEMvGYJ7N2NBaeAgDcMUAWMwsKHIPLG35g6YLVopmsmVBf0KIqWSsHCVncOv01ltwDkyQzlmMFYWiQksBQ2WbzX+iy1ZjdE+wlnAPBdtozWSB2BLpst7sRRRVpb2SLXGVCgZafx3jBFjPj8gQaR6MXyM0CigAFIL6IYAEHpU5AVEFllGeotIfLSOI5LKDcdzX6aO0QAS8pkGJeo0G0sEqFAro5mex1L04ANAE13QYmqFbaeA6LVaP9JZZ5wjgGcXT/jEfIlKGW2EQPcrviWN5mbQKEu3AHD2lrRtZQKYY0XCzPMwPp4M+TDVG3KvSGgOMr2F/csBVoNs3doWAijbauvhIvFgatiWRoUkLUMr3mbBm91nVKrG4nM1TTnyRScteKoF6c25o209GOsXaCwOatiUQw3ahoPJjqeg1W1YsegLXINbgEF5WjBRG6py30heBsABaXfOR1FjQKX5rAOeMZcGYa3d2xKvICYen+O95kBASqBKdlmwyCyxsqeaPcANI2O2roNwTScFNQVpIFrUJyFoFgi7CrAs5RfvTqBy8AdY/wAO0eTadjAdjrcdOU7m4rkok8oswNU0FZ8wCAiaIBKARhoHaQl9W05UpwR9pksJAXV/tz6Uvra4FNLKUgVuuxwlsU8TBSoVLeDx5Y49CEsCVsxd/MpD7butFddVOdexTGZYgxiXe7l6TEukFJDblgK5vwAitZQAIQW3lLqmNLn12VVp4WF6ORLcMvNyh3IZ2HfArh1JXUBtu3T/ABhHWB2EUvkarI81UrnzNaAU0daN6gYtxWJqimsM91wUegMwCrTf26B/9n//2Q==";
    System.out.println(Base64toPic(str));
    // 图片转base64
    str = PictoBase64("C:/Users/Marydon/Desktop/5eec728d12dd49ee8a1e1cc7ad248770.png");
    System.out.println(str);
    
}

 

 

 

你可能感兴趣的:(java 图片与base64相互转化)