mac
2024-04-29 20ad67e1db72d7a8c2824bc75398e37af6b10d66
app/src/main/java/com/hdl/photovoltaic/other/HdlFileLogic.java
@@ -128,13 +128,12 @@
    /**
     * 获取固件升级文件全路径
     *
     * @param oid     该固件oid
     * @param imageId 镜像id
     * @param version 驱动版本
     * @return 全路径
     */
    public String getFirmwarePathFileName(String oid, String imageId, String version) {
        String fileName = oid + "_" + imageId + "_" + version + ".zip";
    public String getFirmwarePathFileName(String imageId, String version) {
        String fileName = imageId + "_" + version + ".zip";
        return HdlFileLogic.getInstance().getFirmwareRootPath() + "/" + fileName;
    }
@@ -315,15 +314,43 @@
            d.flush();
            d.close();
            if (file.length() > 1024 * 1024 * mDataSize) {
                //文件大于1m,删除文件前20条日志
                this.delFileLien(fullPath, 20);
                //文件大于1m,删除文件前100条日志
                this.delFileLien(fullPath, 100);
            }
            System.out.println("写入一行数据到文件成功--->" + dataLine);
//            System.out.println("写入一行数据到文件成功--->" + dataLine);
        } catch (Exception e) {
            System.out.println("写入一行数据到文件有异常--->" + e.getMessage());
//            System.out.println("写入一行数据到文件有异常--->" + e.getMessage());
        }
    }
    /**
     * 读取文件
     *
     * @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);//这个方法不兼用android 6.0
            fis.close();
            System.out.println("读取文件成功--->" + filePath);
            return bytes;
        } catch (Exception e1) {
            System.out.println("读取文件有异常--->" + e1.getMessage());
            return null;
        }
    }
    /**
     * 读取文件
@@ -341,7 +368,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;