|
@@ -71,15 +71,21 @@ public class DmpSoftwareUpgradeServiceImpl extends AbstractCrudService<DmpSoftwa
|
|
|
inputStream = new ByteArrayInputStream(byteArr);
|
|
|
//创建规定大小的byte数组
|
|
|
byte[] b = new byte[num];
|
|
|
- int len = 0;
|
|
|
//name为以后的小文件命名做准备
|
|
|
int name = 0;
|
|
|
//遍历将大文件读入byte数组中,当byte数组读满后写入对应的小文件中
|
|
|
- while ((len = inputStream.read(b)) != -1) {
|
|
|
- int chk = 0x0000;
|
|
|
- for(int i=0;i<len;i++){
|
|
|
- chk += b[i]&0x00ff;
|
|
|
+
|
|
|
+ int len,crc,cur = 0;
|
|
|
+ while((len = inputStream.read(b))!=-1) {
|
|
|
+ crc = 0;
|
|
|
+ for(int i=0;i<len;i++) {
|
|
|
+ String str = Integer.toHexString(b[i]&0x00ff);
|
|
|
+ if(str.length()==1)
|
|
|
+ str = "0"+str;
|
|
|
+ System.out.print(str+" ");
|
|
|
+ crc = (crc + (b[i]&0x00ff))&0xffff;
|
|
|
}
|
|
|
+
|
|
|
DmpSoftwareSubpackage dmpSoftwareSubpackage = new DmpSoftwareSubpackage();
|
|
|
dmpSoftwareSubpackage.setUpgradeId(dmpSoftwareUpgrade.getId());
|
|
|
dmpSoftwareSubpackage.setSubpackageNumber(name);
|
|
@@ -88,10 +94,28 @@ public class DmpSoftwareUpgradeServiceImpl extends AbstractCrudService<DmpSoftwa
|
|
|
dmpSoftwareSubpackage.setApplyPackage(subBytes(b,0,len));
|
|
|
}
|
|
|
dmpSoftwareSubpackage.setSubpackageLength(String.valueOf(len));
|
|
|
- dmpSoftwareSubpackage.setCheckCode(String.format("%04x", chk& 0x0000ffff));
|
|
|
+ dmpSoftwareSubpackage.setCheckCode(Integer.toHexString(crc));
|
|
|
list.add(dmpSoftwareSubpackage);
|
|
|
- name++;
|
|
|
+ System.out.println("\n"+cur+") len:"+len+"\tcrc:"+Integer.toHexString(crc));
|
|
|
+ cur++;
|
|
|
}
|
|
|
+// while ((len = inputStream.read(b)) != -1) {
|
|
|
+// int chk = 0x0000;
|
|
|
+// for(int i=0;i<len;i++){
|
|
|
+// chk += b[i]&0x00ff;
|
|
|
+// }
|
|
|
+// DmpSoftwareSubpackage dmpSoftwareSubpackage = new DmpSoftwareSubpackage();
|
|
|
+// dmpSoftwareSubpackage.setUpgradeId(dmpSoftwareUpgrade.getId());
|
|
|
+// dmpSoftwareSubpackage.setSubpackageNumber(name);
|
|
|
+// dmpSoftwareSubpackage.setApplyPackage(b);
|
|
|
+// if (len < 1024){
|
|
|
+// dmpSoftwareSubpackage.setApplyPackage(subBytes(b,0,len));
|
|
|
+// }
|
|
|
+// dmpSoftwareSubpackage.setSubpackageLength(String.valueOf(len));
|
|
|
+// dmpSoftwareSubpackage.setCheckCode(String.format("%04x", chk& 0x0000ffff));
|
|
|
+// list.add(dmpSoftwareSubpackage);
|
|
|
+// name++;
|
|
|
+// }
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
} finally {
|