From d1048f9bcb1977d4bf244d944270e7bcfe5c2364 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 9 Nov 2007 14:32:33 -0700 Subject: [PATCH] implement ByteBuffer.get(byte[]) --- classpath/java/nio/ByteBuffer.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/classpath/java/nio/ByteBuffer.java b/classpath/java/nio/ByteBuffer.java index 004ebda08c..49bf9cd98d 100644 --- a/classpath/java/nio/ByteBuffer.java +++ b/classpath/java/nio/ByteBuffer.java @@ -138,7 +138,6 @@ public class ByteBuffer { return this; } - public boolean hasRemaining() { return remaining() > 0; } @@ -148,6 +147,17 @@ public class ByteBuffer { return array[arrayOffset+(position++)]; } + public ByteBuffer get(byte[] dst) { + return get(dst, 0, dst.length); + } + + public ByteBuffer get(byte[] dst, int offset, int length) { + checkGet(length); + System.arraycopy(array, arrayOffset + position, dst, offset, length); + position += length; + return this; + } + public byte get(int position) { checkGet(position, 1); return array[arrayOffset+position];