From 1686440f604006a6e145adc4442ddae95e584ded Mon Sep 17 00:00:00 2001 From: "Brian P. Hinz" Date: Thu, 20 Oct 2016 18:06:46 -0400 Subject: [PATCH] Added a method for copying between streams --- java/com/tigervnc/rdr/OutStream.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/java/com/tigervnc/rdr/OutStream.java b/java/com/tigervnc/rdr/OutStream.java index 46fe7346..a3b1a6c0 100644 --- a/java/com/tigervnc/rdr/OutStream.java +++ b/java/com/tigervnc/rdr/OutStream.java @@ -116,6 +116,17 @@ abstract public class OutStream { } } + // copyBytes() efficiently transfers data between streams + + public void copyBytes(InStream is, int length) { + while (length > 0) { + int n = check(1, length); + is.readBytes(b, ptr, n); + ptr += n; + length -= n; + } + } + // writeOpaqueN() writes a quantity without byte-swapping. Because java has // no byte-ordering, we just use big-endian. -- 2.39.5