Android Question Search byte sequence in file, and extract portions from it

designer2k2

Member
Licensed User
Longtime User
Hello,

im lost in searching for a way to get this done :(

I have a file, where i need to find 2 byte sequences, and then extract the data between this 2 positions into a new file.

This is simple in python:
B4X:
pos1 = data.find(bytes([0x13, 0x43, 0x44, 0x3f])
pos2 = data.find(bytes([0x12, 0x34, 0x3f])
new = data[pos1:pos2-pos1]

but in B4A the byte array has no search function? o_O

I read the file like this:
B4X:
Dim b as Bytes()
b = File.ReadBytes(Dir,Path)

Any idea or direction what i can follow up to get this going?

greetings,
d2k2
 

DonManfred

Expert
Licensed User
Longtime User
Use bytesbuilder. I guess it should be doable with it.
 
Last edited:
Upvote 0
Top