I'm not sure if this is even possible. Suppose I have an infinite incoming stream of characters, and I want to find the first match of a certain string (say, a short word). Is it possible to implement it using Java's stream API?
The only obvious algorithm I can think of is that if the first charater of the word is encountered in the stream, check the next character from the stream, and if it equals the next charater of the word, check the 3rd character. Because the word or pattern only has a few charaters, this algorithm sounds plausible. But I find it very difficult to implement with the stream API. I was wondering if it's possible to achieve this.It might be theoritically impossible.
Aucun commentaire:
Enregistrer un commentaire