pdf转base64


public static String pdfToBase64() {
InputStream is = null;
ByteArrayOutputStream os = null;
String dUrlData="";
byte[] buff = new byte[1024];
int len = 0;
try {
is = new FileInputStream(new File("C:\\Users\\Administrator\\Desktop\\文档\\接口文档-修改版.pdf"));
os = new ByteArrayOutputStream();
while ((len = is.read(buff)) != -1) {
os.write(buff, 0, len);
}
os.flush();
os.toByteArray();
dUrlData = Base64.getEncoder().encodeToString(os.toByteArray());
} catch (IOException e) {
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {}
}
if (os != null) {
try {
os.close();
} catch (IOException e) {}
}
}
return dUrlData;
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM