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;
}