/** * Read a single line of ASCII text from a byte buffer, appending the results to the given string * builder. If no {@code EOL} character is encountered, {@code false} is returned, indicating that more data needs * to be acquired before the operation can be complete. On return, there may be data remaining * in the source buffer. If an invalid byte is read, the character {@code '?'} is written * to the string builder in its place. The {@code EOL} character will be included in the resultant string. * * @param src the source buffer * @param builder the destination builder * @return {@code true} if the entire string was read, {@code false} if more data is needed */ public static boolean readAsciiLine(final ByteBuffer src, final StringBuilder builder) { return readAsciiLine(src, builder, '?', '\n'); }
/** * Read a single line of ASCII text from a byte buffer, appending the results to the given string * builder. If no {@code EOL} character is encountered, {@code false} is returned, indicating that more data needs * to be acquired before the operation can be complete. On return, there may be data remaining * in the source buffer. If an invalid byte is read, the character designated by {@code replacement} is written * to the string builder in its place. The {@code EOL} character will be included in the resultant string. * * @param src the source buffer * @param builder the destination builder * @param replacement the replacement character for invalid bytes * @return {@code true} if the entire string was read, {@code false} if more data is needed */ public static boolean readAsciiLine(final ByteBuffer src, final StringBuilder builder, final char replacement) { return readAsciiLine(src, builder, replacement, '\n'); }
/** * Read a single line of ASCII text from a byte buffer, appending the results to the given string * builder. If no {@code EOL} character is encountered, {@code false} is returned, indicating that more data needs * to be acquired before the operation can be complete. On return, there may be data remaining * in the source buffer. If an invalid byte is read, the character {@code '?'} is written * to the string builder in its place. The {@code EOL} character will be included in the resultant string. * * @param src the source buffer * @param builder the destination builder * @return {@code true} if the entire string was read, {@code false} if more data is needed */ public static boolean readAsciiLine(final ByteBuffer src, final StringBuilder builder) { return readAsciiLine(src, builder, '?', '\n'); }
/** * Read a single line of ASCII text from a byte buffer, appending the results to the given string * builder. If no {@code EOL} character is encountered, {@code false} is returned, indicating that more data needs * to be acquired before the operation can be complete. On return, there may be data remaining * in the source buffer. If an invalid byte is read, the character designated by {@code replacement} is written * to the string builder in its place. The {@code EOL} character will be included in the resultant string. * * @param src the source buffer * @param builder the destination builder * @param replacement the replacement character for invalid bytes * @return {@code true} if the entire string was read, {@code false} if more data is needed */ public static boolean readAsciiLine(final ByteBuffer src, final StringBuilder builder, final char replacement) { return readAsciiLine(src, builder, replacement, '\n'); }