public static Optional < String > readMaybeString ( ByteBuf bf ) { Optional < byte [ ] > bytes = readMaybeRangedBytes ( bf ) ; return bytes . map ( b -> { if ( b . length == 0 ) return "" ; else return new String ( b , CharsetUtil . UTF_8 ) ; } ) ; }
Reads a string if possible . If not present the reader index is reset to the last mark .