diff options
author | Brian P. Hinz <bphinz@users.sf.net> | 2016-10-20 18:04:37 -0400 |
---|---|---|
committer | Brian P. Hinz <bphinz@users.sf.net> | 2016-10-20 18:04:37 -0400 |
commit | 5a9e7a9c4b2165e2ba9424a5946abe807e208594 (patch) | |
tree | e12ba12ce5faf48309e92c3ba4adac5b777cf9e7 /java | |
parent | b1d6b55b08c5060bbab8de654a8b95e616817873 (diff) | |
download | tigervnc-5a9e7a9c4b2165e2ba9424a5946abe807e208594.tar.gz tigervnc-5a9e7a9c4b2165e2ba9424a5946abe807e208594.zip |
Added a method for reading into a ByteBuffer
Diffstat (limited to 'java')
-rw-r--r-- | java/com/tigervnc/rdr/InStream.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/java/com/tigervnc/rdr/InStream.java b/java/com/tigervnc/rdr/InStream.java index 3938a327..f713d738 100644 --- a/java/com/tigervnc/rdr/InStream.java +++ b/java/com/tigervnc/rdr/InStream.java @@ -23,6 +23,8 @@ package com.tigervnc.rdr; +import java.nio.*; + import com.tigervnc.network.*; abstract public class InStream { @@ -98,6 +100,16 @@ abstract public class InStream { // readBytes() reads an exact number of bytes into an array at an offset. + public void readBytes(ByteBuffer data, int length) { + int dataEnd = data.mark().position() + length; + while (data.position() < dataEnd) { + int n = check(1, dataEnd - data.position()); + data.put(b, ptr, n); + ptr += n; + } + data.reset(); + } + public void readBytes(byte[] data, int dataPtr, int length) { int dataEnd = dataPtr + length; while (dataPtr < dataEnd) { |