java - How to do a search between a range offsets in a Binary file? -
i'm trying search between range of offsets in binary file. have loaded bin file byte array[] , encoded content string, later use search of string sequence. thing need search in range of offset input (start , ending)... , search differents string sequences, printing gives me this:
0x180 30 0x240 17 0x350 30 0x464 30 0x650 17
right i'm getting sequences 30 themselves.
this code:
byte[] model = read.readbytesfromfile(); string x = hexbin.encode(model); string v30 = "05805a6c"; string v17 = "0580336c"; string beg = txtbeg.gettext().tostring(); int beg2 = integer.parseint(beg); int start = (model.length + beg2) - model.length; string end = txtend.gettext().tostring(); int end2 = integer.parseint(end); int ending = (model.length + end2) - model.length; int index = 0; if (x.contains(v30) { if (cbxver.isselected()) { while ((index = x.indexof(v30, index)) != -1) { system.out.println("0x" + (integer.tohexstring((index / 2) + 4)) + " 30"); index = index + 2; } } } else { joptionpane.showmessagedialog(rootpane, "wrong file"); }
Comments
Post a Comment