I myself could not reproduce this. But I think I can shed light on what is happening.
Inside the scanner, a character buffer of 1024 characters is used. The scanner will read from your Readable 1024 characters by default, if possible, and then apply the template.
The problem is in your template ... it will always correspond to the end of the input, but that does not mean the end of your input stream / data. When Java applies your pattern to buffered data, it tries to find the first occurrence of the end of the input. Since there are 1024 characters in the buffer, the corresponding engine calls position 1024, the first match of the delimiter and all before it is returned as the first token.
I do not think that the end-of-entry anchor is valid for use in the Scanner for this reason. In the end, it could be reading from an endless stream.
Mark peters
source share