diff options
Diffstat (limited to 'java/src/main/java/com/google/protobuf/ByteString.java')
-rw-r--r-- | java/src/main/java/com/google/protobuf/ByteString.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/java/src/main/java/com/google/protobuf/ByteString.java b/java/src/main/java/com/google/protobuf/ByteString.java index 5fade03a..91356357 100644 --- a/java/src/main/java/com/google/protobuf/ByteString.java +++ b/java/src/main/java/com/google/protobuf/ByteString.java @@ -194,6 +194,18 @@ public final class ByteString { } /** + * Copies bytes into a ByteBuffer. + * + * @param target ByteBuffer to copy into. + * @throws ReadOnlyBufferException if the {@code target} is read-only + * @throws BufferOverflowException if the {@code target}'s remaining() + * space is not large enough to hold the data. + */ + public void copyTo(ByteBuffer target) { + target.put(bytes, 0, bytes.length); + } + + /** * Copies bytes to a {@code byte[]}. */ public byte[] toByteArray() { |