一、背景
后台生成文件,需要传给前台
二、两种思路
-
用流输出
前端不好接收,无法将返回码一起传输出去 -
通过Base64传输
JDK1.7
import sun.misc.BASE64Encoder;
byte[] bytes = "abc".getBytes();
String str = Base64.encodeToString(bytes ,Base64.DEFAULT);
JDK1.8 (移除了上述的jar)
import org.apache.commons.codec.binary.Base64
byte[] bytes = "abc".getBytes();
String appletCode = Base64.encodeBase64String(bytes );