Java push back buffer is full

Why the push back buffer is full exception happens? Let's first see what is a push back buffer.

A push back buffer is an internal buffer inside a push back reader. And a push back reader is just a wrapper on an input stream. The stream can comes from string, file or standard IO,

As the name indicated, this kind of read can read or unread(push back) chars from stream.

The read operation will free spaces in push back buffer, one slot a time and unread will consume the buffer.

By default, the buffer size is 1, which means one unread operation will make it full and one read operation will make it empty.

You get this buffer full because there are more unread operations than read. For example one read and following two unread operations will throw this exception.

You should check the buffer size and how it was used.

The easiest solution will be increase the buffer size on construction.

( ( ( (.getBytes "hello\n"))) 100)