I made a search method because I want to use binary data like PNG files. The point of this is to be able to find strings like IEND
in a PNG file. I think it works properly. Any improvements/fixes would be appreciated.
public static int findString(byte[] in, byte[] find) {
boolean done = false;
for(int i = 0; i < in.length; i++) {
if(in[i] == find[0]) {
for(int ii = 1; ii < find.length; i++) {
if(in[i+ii] != find[ii]) break;
else if(ii==find.length-1) done = true;
}
if(done) return i-1;
}
}
return -1;
}