@ Nonnull public String getLine ( ) { if ( preLoaded ) { if ( bufferOffset >= 0 ) { int lineStart = bufferOffset ; if ( linePos > 0 ) { lineStart -= linePos - 1 ; } int lineEnd = bufferOffset ; while ( lineEnd < bufferLimit && buffer [ lineEnd ] != ' ' ) { ++ lineEnd ; } return new String ( buffer , lineStart , lineEnd - lineStart ) ; } } else if ( bufferLimit > 0 ) { if ( Math . abs ( ( linePos - 1 ) - bufferOffset ) < 2 ) { // only return the line if the line has not been consolidated before the // exception. This should avoid showing a bad exception line pointing to // the wrong content. This should never be the case in pretty-printed // JSON unless some really really long strings are causing the error. // // Since linePos does not exactly follow offset, we must accept +- 1. return new String ( buffer , 0 , bufferLimit - ( bufferLineEnd ? 1 : 0 ) ) ; } } // Otherwise we don't have the requested line, return empty string. return "" ; }
Returns the current line in the buffer . Or empty string if not usable .