public static void copyToView(
			MemorySegment[] segments,
			int offset,
			int sizeInBytes,
			DataOutputView target) throws IOException {
		for (MemorySegment sourceSegment : segments) {
			int curSegRemain = sourceSegment.size() - offset;
			if (curSegRemain > 0) {
				int copySize = Math.min(curSegRemain, sizeInBytes);

				byte[] bytes = allocateReuseBytes(copySize);
				sourceSegment.get(offset, bytes, 0, copySize);
				target.write(bytes, 0, copySize);

				sizeInBytes -= copySize;
				offset = 0;
			} else {
				offset -= sourceSegment.size();
			}

			if (sizeInBytes == 0) {
				return;
			}
		}

		if (sizeInBytes != 0) {
			throw new RuntimeException("No copy finished, this should be a bug, " +
					"The remaining length is: " + sizeInBytes);
		}
	}
public static void copyToView ( MemorySegment [ ] segments , int offset , int sizeInBytes , DataOutputView target ) throws IOException { for ( MemorySegment sourceSegment : segments ) { int curSegRemain = sourceSegment . size ( ) - offset ; if ( curSegRemain > 0 ) { int copySize = Math . min ( curSegRemain , sizeInBytes ) ; byte [ ] bytes = allocateReuseBytes ( copySize ) ; sourceSegment . get ( offset , bytes , 0 , copySize ) ; target . write ( bytes , 0 , copySize ) ; sizeInBytes -= copySize ; offset = 0 ; } else { offset -= sourceSegment . size ( ) ; } if ( sizeInBytes == 0 ) { return ; } } if ( sizeInBytes != 0 ) { throw new RuntimeException ( "No copy finished, this should be a bug, " + "The remaining length is: " + sizeInBytes ) ; } }
Copy bytes of segments to output view.
Note: It just copies the data in, not include the length.

@param segments    source segments
@param offset      offset for segments
@param sizeInBytes size in bytes
@param target      target output view