Code examples for ByteBuffer

Codota analyzed 7,668,838 open source code samples to find the most common, credible and clear examples.
You can now enable Codota on your own code to easily search and navigate your Java codebase.
98:	if (buffer.hasArray()) { 
99:	return new BytesArray(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining()); 
Full Snippet Info
10
CodeRank
83:	bb.limit(Math.min(off + len, bb.capacity())); 
84:	bb.position(off); 
-
88:	int read = channel.read(bb, position); 
Full Snippet Info
9
CodeRank
43:	return o2.remaining() == 0 ? 0 : -1; 
-
45:	if (o2.remaining() == 0) 
-
50:	int diff = o1.get(o1.position() + o1.arrayOffset()) - o2.get(o2.position() + o2.arrayOffset()); 
-
54:	return ByteBufferUtil.compareUnsigned(o1, o2); 
Full Snippet Info
9
CodeRank
35:	if (!buffer.hasRemaining()) { 
-
39:	len = Math.min(len, buffer.remaining()); 
40:	buffer.get(b, off, len); 
Full Snippet Info
9
CodeRank
53:	bb.position(pos); 
54:	bb.mark(); 
55:	bb.put(s.getBytes()); 
56:	bb.reset(); 
57:	assert bb.position() == pos; 
-
68:	assert s.equals(ByteBufferUtil.string(bb, 10, s.length())); 
-
71:	assert s.equals(ByteBufferUtil.string(bb, 10, s.length())); 
Full Snippet Info
9
CodeRank
40:	return o2.remaining() == 0 ? 0 : -1; 
-
42:	if (o2.remaining() == 0) 
-
47:	int diff = o1.get(o1.position()) - o2.get(o2.position()); 
-
52:	return ByteBufferUtil.compareUnsigned(o1, o2); 
Full Snippet Info
9
CodeRank
50:	Assert.assertEquals(0, newBuffer.position()); 
51:	Assert.assertEquals(10, newBuffer.capacity()); 
52:	Assert.assertEquals(10, newBuffer.limit()); 
53:	Assert.assertEquals(10, newBuffer.remaining()); 
54:	Assert.assertTrue(newBuffer.isDirect()); 
-
64:	Assert.assertEquals(0, newBuffer.position()); 
65:	Assert.assertEquals(10, newBuffer.capacity()); 
66:	Assert.assertEquals(10, newBuffer.limit()); 
67:	Assert.assertEquals(10, newBuffer.remaining()); 
68:	Assert.assertTrue(newBuffer.isDirect()); 
Full Snippet Info
9
CodeRank
103:	size = (buffer.remaining() - numBufferBytes) / numBytes; 
-
170:	byte versionFromBuffer = buffer.get(); 
-
173:	int numBytes = buffer.get(); 
174:	int size = buffer.getInt(); 
175:	ByteBuffer bufferToUse = buffer.asReadOnlyBuffer(); 
176:	bufferToUse.limit(bufferToUse.position() + size); 
177:	buffer.position(bufferToUse.limit()); 
Full Snippet Info
9
CodeRank
105:	if (buffer.hasArray()) { 
106:	return new BytesArray(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining()); 
Full Snippet Info
8
CodeRank
173:	byteBuffer.put(startKey.getBytes(), 0, startKey.getLength()); 
174:	byteBuffer.put(newline); 
-
176:	byteBuffer.put(endKey.getBytes(), 0, endKey.getLength()); 
177:	byteBuffer.put(newline); 
-
182:	byteBuffer.flip(); 
183:	ByteBuffer tmpByteBuf = byteBuffer.slice(); 
-
193:	byteBuffer.clear(); 
Full Snippet Info
8
CodeRank
32:	cloned.mark(); 
33:	cloned.put(buffer.duplicate()); 
34:	cloned.reset(); 
Full Snippet Info
8
CodeRank
40:	int length = (bb.get() & 0xFF) << 8; 
41:	return length | (bb.get() & 0xFF); 
-
54:	ByteBuffer copy = bb.duplicate(); 
55:	copy.limit(copy.position() + length); 
56:	bb.position(bb.position() + length); 
Full Snippet Info
8
CodeRank
191:	int willActuallyRead = randomInt(dst.remaining()); 
192:	ByteBuffer mockDst = dst.duplicate(); 
193:	mockDst.limit(mockDst.position() + willActuallyRead); 
-
195:	return delegate.read(mockDst); 
-
197:	dst.position(mockDst.position()); 
Full Snippet Info
8
CodeRank
34:	int size = buffer.getInt(); 
35:	ByteBuffer bufferToUse = buffer.asReadOnlyBuffer(); 
36:	bufferToUse.limit(bufferToUse.position() + size); 
37:	buffer.position(bufferToUse.limit()); 
-
39:	return strategy.fromByteBuffer(bufferToUse, size); 
Full Snippet Info
9
CodeRank
41:	if ((bytes == null) || !bytes.hasRemaining()) { 
-
45:	ByteBuffer dup = bytes.duplicate(); 
46:	int l = dup.remaining(); 
47:	ByteArrayInputStream bais = new ByteArrayInputStream(dup.array(), 
48:	dup.arrayOffset() + dup.position(), l); 
-
51:	dup.position(dup.position() + (l - ois.available())); 
Full Snippet Info
8
CodeRank
59:	if (lastWritable == null && buffer.position() == 0) { 
-
74:	while (buffer.hasRemaining() && lastWritable != null) { 
75:	boolean complete = lastWritable.writeTo(buffer); 
-
82:	if (buffer.position() > 0) { 
83:	buffer.flip(); 
-
85:	socketChannel.write(buffer); 
-
91:	if (buffer.hasRemaining()) { 
92:	buffer.compact(); 
-
94:	buffer.clear(); 
Full Snippet Info
8
CodeRank
64:	if (n > buffer.remaining()) { 
65:	int ret = buffer.position(); 
66:	buffer.position(buffer.limit()); 
-
69:	buffer.position((int) (buffer.position() + n)); 
Full Snippet Info
8
CodeRank
47:	ByteBuffer mutationBuffer = buf.duplicate(); 
48:	mutationBuffer.position(position); 
-
51:	mutationBuffer.asLongBuffer().put(bins); 
52:	mutationBuffer.putFloat(position + minOffset, Float.MAX_VALUE); 
53:	mutationBuffer.putFloat(position + maxOffset, Float.MIN_VALUE); 
Full Snippet Info
9
CodeRank
142:	if (!source.hasRemaining()) { 
-
145:	byte version = source.get(); 
-
153:	if (source.remaining() < 2) { 
-
156:	header = source.getShort(); 
-
160:	if (source.remaining() < 4) { 
-
163:	partitionId = source.getInt(); 
-
166:	return super.readFrom(source); 
Full Snippet Info
8
CodeRank
41:	return new String(bb.array(), bb.position() + bb.arrayOffset(), bb.remaining(), "UTF-8"); 
Full Snippet Info
8
CodeRank