|
@@ -162,4 +162,47 @@ public class ReportServiceImpl implements IReportService {
|
|
|
|
|
|
return "";
|
|
return "";
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String pic2Base64FromPath(String filePath) {
|
|
|
|
+
|
|
|
|
+ FileInputStream fileInputStream = null;
|
|
|
|
+ ByteArrayOutputStream byteArrayOutputStream = null;
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ fileInputStream = new FileInputStream(filePath);
|
|
|
|
+
|
|
|
|
+ byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
|
+
|
|
|
|
+ byte[] bytes = new byte[10240];
|
|
|
|
+ int mReadLength = 0;
|
|
|
|
+
|
|
|
|
+ while ((mReadLength = fileInputStream.read(bytes)) != -1) {
|
|
|
|
+ byteArrayOutputStream.write(bytes, 0, mReadLength);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return Base64.getEncoder().encodeToString(byteArrayOutputStream.toByteArray());
|
|
|
|
+ }catch (Exception e) {
|
|
|
|
+
|
|
|
|
+ }finally {
|
|
|
|
+ if (fileInputStream != null) {
|
|
|
|
+ try {
|
|
|
|
+ fileInputStream.close();
|
|
|
|
+ }catch (Exception e) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (byteArrayOutputStream != null) {
|
|
|
|
+ try {
|
|
|
|
+ byteArrayOutputStream.close();
|
|
|
|
+ }catch (Exception e) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return "";
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|