zoukankan      html  css  js  c++  java
  • base64转图片

    /**
    *
    * @param base64Str
    * @param path
    * @return
    */
    public static File base642File(String base64Str, String path) {
    if (!StringUtils.isNotBlank(base64Str)) {
    return null;
    }
    if (!StringUtils.isNotBlank(path)) {
    return null;
    }
    BASE64Decoder decoder = new BASE64Decoder();
    byte[] b = new byte[0];
    try {
    b = decoder.decodeBuffer(base64Str);
    for (int i = 0; i < b.length; ++i) {
    if (b[i] < 0) {
    b[i] += 256;
    }
    }
    OutputStream out = new FileOutputStream(path);
    out.write(b);
    out.flush();
    out.close();
    log.info("根据base64字符串 生成图片成功。");
    return new File(path);
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }

    return null;
    }
  • 相关阅读:
    1.13 Flask
    1.12 Flask 复习
    1.11 flask
    1.10 flask
    1.9 flask
    1.8 flask 路由
    sql server存储过程
    Ajax学习笔记
    随机密码字典生成器
    jRazor
  • 原文地址:https://www.cnblogs.com/gnpugongying/p/15559988.html
Copyright © 2011-2022 走看看