通过base64下载文件
package com.example.demo.controller;
//需要rt.jar包
import sun.misc.BASE64Decoder;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* Created by LQ on 2021/7/30.
*/
public class Base64ToWordController {
public static void main(String[] args){
try {
// StringBuffer stringBuffer = new StringBuffer();
// stringBuffer.append("0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAOwAD*********");
// byte[] buffer = new BASE64Decoder().decodeBuffer(stringBuffer.toString());
// FileOutputStream out = new FileOutputStream("F:\\a.xls");
// out.write(buffer);
// out.close();
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("QSwUGAAAAAAsACwDBAgAAAi0AAAAA******");
byte[] buffer = new BASE64Decoder().decodeBuffer(stringBuffer.toString());
FileOutputStream out = new FileOutputStream("F:\\rr.docx");
out.write(buffer);
out.close();
}
catch (IOException e){
}
}
}