As #PushbackInputStream is quite similar to #BufferedInputStream, it was rather easy for me to apply the performance optimizations I already developed for BufferedInputStream to the PushbackInputStream. The contribution was accepted in November 2022, so it is now part of #OpenJDK (aka #Java) 20.
The change will make your application #transferTo bytes faster in case your source or target is a file stream and you wrapped it using a PushbackInputStream. For example, if you read the magic byte of a file to find out about the file type, then push it back and transferTo() the complete content to a specific image processing algorithm, the bytes will not walk through the in-memory buffer anymore, sparing processing time.
If you missed the original contribution last year, check my channel page, it is covered by a four-parts series!
If you like this video, please give it a thumbs up, share it, subscribe to my channel, or become my patreon https://www.patreon.com/mkarg. Thanks! 🙂