You can convert ByteBuffer to String and use indexOf, which can work.
ByteBuffer bb = String text = new String(bb.array(), 0, bb.position(), bb.remaing()); int index = text.indexOf(searchText);
This has non-trivial overhead as it creates a string. An alternative is finding brute-force strings that will be faster, but take time to write.
source share