Package io.pravega.common.util
Class ByteBufferUtils
- java.lang.Object
-
- io.pravega.common.util.ByteBufferUtils
-
public class ByteBufferUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.nio.ByteBufferEMPTY
-
Constructor Summary
Constructors Constructor Description ByteBufferUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcopy(java.nio.ByteBuffer from, java.nio.ByteBuffer to)Copies data from the provided `from` buffer to the provided `to` buffer.static java.nio.ByteBufferslice(java.nio.ByteBuffer orig, int begin, int length)
-
-
-
Method Detail
-
slice
public static java.nio.ByteBuffer slice(java.nio.ByteBuffer orig, int begin, int length)
-
copy
public static int copy(java.nio.ByteBuffer from, java.nio.ByteBuffer to)Copies data from the provided `from` buffer to the provided `to` buffer. The data is copied starting from theBuffer.position()of the buffer to itsBuffer.limit(). As much data as possible will be copied without going beyond theBuffer.limit()of the `to` buffer. So if the `to` buffer is too small to hold the data in the `from` buffer, only the portion that will fit is copied. The position of the `from` and `to` buffers will be advanced by the amount of data copied.- Parameters:
from- the buffer to copy fromto- the buffer to copy into- Returns:
- the number of bytes copied
-
-