| | |
| | | |
| | | private static final int hexFileMinLine = 4 ; |
| | | private static final int lineHeadEndIndex = 9 ; |
| | | private static final int lineValidCharCount = 43 ;//每行有效字符(冒号与十六进制)个数,例如:1096C000DC96010010020020203E00000441000052,但倒数第3行不受限制 |
| | | private static final int bytesSplitUnit512 = 512 ; |
| | | |
| | | public static void main(String[] args) throws Exception{ |
| | |
| | | if(!line.startsWith(":")){ |
| | | vo.errors.add("第" + counter + "行内容不是以:开头") ; |
| | | }else{ |
| | | line = line.substring(lineHeadEndIndex, line.length() - 2) ; |
| | | if(vo.bytes.length == 0){ |
| | | vo.bytes = HexUtil.decodeHex(line) ; |
| | | if(counter != vo.totalLines - 3 && line.length() != lineValidCharCount){ |
| | | //无效数据,舍弃本行数据 |
| | | }else{ |
| | | byte[] bytes = HexUtil.decodeHex(line) ; |
| | | vo.bytes = ByteUtil.bytesMerge(vo.bytes, bytes) ; |
| | | line = line.substring(lineHeadEndIndex, line.length() - 2) ; |
| | | if(vo.bytes.length == 0){ |
| | | vo.bytes = HexUtil.decodeHex(line) ; |
| | | }else{ |
| | | byte[] bytes = HexUtil.decodeHex(line) ; |
| | | vo.bytes = ByteUtil.bytesMerge(vo.bytes, bytes) ; |
| | | } |
| | | } |
| | | } |
| | | } |