@@ -50,11 +50,13 @@ public PeekableInputStream(final InputStream inputStream, final int bufferSize)
5050 }
5151
5252 /**
53- * Returns whether the next bytes in the buffer are as given by {@code sourceBuffer}. This is equivalent to
54- * {@link #peek(byte[], int, int)} with {@code offset} == 0, and {@code length} == {@code sourceBuffer.length}
53+ * Returns whether the next bytes in the buffer exactly match {@code sourceBuffer}. This is equivalent to
54+ * {@link #peek(byte[], int, int)} with {@code offset} == 0, and {@code length} == {@code sourceBuffer.length}.
55+ * This method does not perform a prefix or starts-with check; for example, peeking {@code "Some"} against a stream
56+ * containing {@code "Some text buffer"} returns {@code false}. This method does not consume bytes from the stream.
5557 *
5658 * @param sourceBuffer the buffer to compare against.
57- * @return true if the next bytes are as given .
59+ * @return true if the next bytes exactly match {@code sourceBuffer} .
5860 * @throws IOException Refilling the buffer failed.
5961 */
6062 public boolean peek (final byte [] sourceBuffer ) throws IOException {
@@ -63,13 +65,13 @@ public boolean peek(final byte[] sourceBuffer) throws IOException {
6365 }
6466
6567 /**
66- * Returns whether the next bytes in the buffer are as given by {@code sourceBuffer}, { code offset }, and
67- * {@code length} .
68+ * Returns whether the next bytes in the buffer exactly match {@code length} bytes from {@ code sourceBuffer }, starting at
69+ * {@code offset}. This method does not consume bytes from the stream .
6870 *
6971 * @param sourceBuffer the buffer to compare against.
70- * @param offset the start offset.
72+ * @param offset the start offset in {@code sourceBuffer} .
7173 * @param length the length to compare.
72- * @return true if the next bytes in the buffer are as given .
74+ * @return true if the next bytes exactly match the requested range from {@code sourceBuffer} .
7375 * @throws IOException if there is a problem calling fillBuffer().
7476 */
7577 public boolean peek (final byte [] sourceBuffer , final int offset , final int length ) throws IOException {
0 commit comments