@@ -42,6 +42,21 @@ default void toByteBuffer(ByteBuffer dest) {
4242 toByteBuffer (0 , dest , dest .position (), size ());
4343 }
4444
45+ /**
46+ * Copies the given length from this data buffer into the given destination {@code ByteBuffer},
47+ * beginning at the given source position, and the given destination position in the destination
48+ * byte buffer.
49+ *
50+ * @param srcPos the position of this data buffer from where copying should start
51+ * @param dest the destination byte buffer
52+ * @param destPos the position in {@code dest} to where copying should start
53+ * @param length the amount of data to copy
54+ */
55+ default void toByteBuffer (int srcPos , ByteBuffer dest , int destPos , int length ) {
56+ dest = dest .duplicate ().clear ();
57+ dest .put (destPos , asByteBuffer (), srcPos , length );
58+ }
59+
4560 default Iterator <ByteBuffer > split (IntPredicate predicate ) {
4661 // TODO: fix me for chunks
4762 var buffer = asByteBuffer ();
@@ -60,21 +75,6 @@ default Iterator<ByteBuffer> split(IntPredicate predicate) {
6075 return chunks .iterator ();
6176 }
6277
63- /**
64- * Copies the given length from this data buffer into the given destination {@code ByteBuffer},
65- * beginning at the given source position, and the given destination position in the destination
66- * byte buffer.
67- *
68- * @param srcPos the position of this data buffer from where copying should start
69- * @param dest the destination byte buffer
70- * @param destPos the position in {@code dest} to where copying should start
71- * @param length the amount of data to copy
72- */
73- default void toByteBuffer (int srcPos , ByteBuffer dest , int destPos , int length ) {
74- dest = dest .duplicate ().clear ();
75- dest .put (destPos , asByteBuffer (), srcPos , length );
76- }
77-
7878 void accept (SneakyThrows .Consumer <ByteBuffer > consumer );
7979
8080 default Iterator <ByteBuffer > iterator () {
0 commit comments