]> source.dussan.org Git - tigervnc.git/commitdiff
Added a method for copying between streams
authorBrian P. Hinz <bphinz@users.sf.net>
Thu, 20 Oct 2016 22:06:46 +0000 (18:06 -0400)
committerBrian P. Hinz <bphinz@users.sf.net>
Thu, 20 Oct 2016 22:06:46 +0000 (18:06 -0400)
java/com/tigervnc/rdr/OutStream.java

index 46fe73465288e372e223311db551fa6b2ed5b78b..a3b1a6c0f6c4779c8839204937e8c158c046fd95 100644 (file)
@@ -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.