Spent ~30 "quality" minutes trying to figure out how to find a sequence of bytes in another sequence of bytes… in .

- "just copy-paste this Knuth-Morris-Pratt implementation" (you're kidding me?)
- "just convert to String and use .indexOf" (ever seen non-ascii bytes?)
- "just use Google Guava" (whatever that is)

Turns out, there is a way… But first I have to think of my ByteBuffer as of byte array, then that as of List, and *then* I have Collections.indexOfSubList.

… well that didn't work either. Turns out that in order to turn a byte array into a list you need to *box all the bytes*, which defeats the point of doing anything low level.

Sign in to participate in the conversation

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!