From 976d3d484b25ea184a5da6968d4ad18605e5aa86 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期二, 23 一月 2024 16:19:20 +0800
Subject: [PATCH] 2024年01月23日16:19:09
---
app/src/main/java/com/hdl/photovoltaic/other/HdlFileLogic.java | 34 +++++++++++++++++++++++++++++++++-
1 files changed, 33 insertions(+), 1 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlFileLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlFileLogic.java
index 81e6ddc..cb44355 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlFileLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlFileLogic.java
@@ -331,6 +331,34 @@
* @param filePath 鍏ㄨ矾寰�
* @return 鏁版嵁
*/
+ public byte[] readFileByte1(String filePath) {
+ try {
+ if (!isBoolean(filePath)) {
+ return null;
+ }
+ File f = new File(filePath);
+ if (!f.exists()) {
+ return null;
+ }
+ FileInputStream fis = new FileInputStream(f);
+ byte[] bytes = FileUtils.readFileToByteArray(f);//杩欎釜鏂规硶涓嶅吋鐢╝ndroid 6.0
+ fis.close();
+ System.out.println("璇诲彇鏂囦欢鎴愬姛--->" + filePath);
+ return bytes;
+ } catch (Exception e1) {
+ System.out.println("璇诲彇鏂囦欢鏈夊紓甯�--->" + e1.getMessage());
+ return null;
+ }
+
+ }
+
+
+ /**
+ * 璇诲彇鏂囦欢
+ *
+ * @param filePath 鍏ㄨ矾寰�
+ * @return 鏁版嵁
+ */
public byte[] readFileByte(String filePath) {
try {
if (!isBoolean(filePath)) {
@@ -341,7 +369,11 @@
return null;
}
FileInputStream fis = new FileInputStream(f);
- byte[] bytes = FileUtils.readFileToByteArray(f);
+ BufferedInputStream bis = new BufferedInputStream(fis);
+ int fileLength = (int) f.length();
+ byte[] bytes = new byte[fileLength];
+ int len = bis.read(bytes);
+ bis.close();
fis.close();
System.out.println("璇诲彇鏂囦欢鎴愬姛--->" + filePath);
return bytes;
--
Gitblit v1.8.0