• base64文件保存


    public static void base64ToFile(String base64, String fileName, String savePath) {
    File file = null;
    //创建文件目录
    String filePath = savePath;
    File dir = new File(filePath);
    if (!dir.exists() && !dir.isDirectory()) {
    dir.mkdirs();
    }
    BufferedOutputStream bos = null;
    java.io.FileOutputStream fos = null;
    try {
    byte[] bytes = Base64.getDecoder().decode(base64);
    file=new File(filePath + fileName);
    fos = new java.io.FileOutputStream(file);
    bos = new BufferedOutputStream(fos);
    bos.write(bytes);
    } catch (Exception e) {
    e.printStackTrace();
    } finally {
    if (bos != null) {
    try {
    bos.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    if (fos != null) {
    try {
    fos.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }
    }
  • 相关阅读:
    五月杂题选做
    BJOI 2021 游记&题解
    U149858
    CF1037简要题解
    CF Round706简要题解
    联合省选 2020
    九省联考 2018 IIIDX
    九省联考 2018 秘密袭击
    AGC006F Balckout
    概率生成函数学习笔记
  • 原文地址:https://www.cnblogs.com/keyi/p/15044018.html
Copyright © 2020-2023  润新知