这里导出的是EXCLE文件,其他文件需要改一下后缀( .xlsx )
public static void download (byte [] bs) {
InputStream inputStream = new ByteArrayInputStream(bs);
OutputStream os = null;
String path = "C:\\Users\\Administrator\\Desktop\\导出文件";
// 输出的文件流保存到本地文件
File tempFile = new File(path);
if (!tempFile.exists()) {
tempFile.mkdirs();
}
try {
os = new FileOutputStream(tempFile.getPath() + File.separator + System.currentTimeMillis()+".xlsx");
// 开始读取
int len;
while ((len = inputStream.read(bs)) != -1) {
os.write(bs, 0, len);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
os.close();
inputStream.close();
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
--------------------------------------------------
❤ 如果本篇博客对您有一定的帮助,大家记得点赞、留言、关注哦❤
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓