1 32 package com.imagero.uio.io; 33 34 import java.io.ByteArrayOutputStream ; 35 36 40 public class ByteArrayOutputStreamExt extends ByteArrayOutputStream { 41 42 public ByteArrayOutputStreamExt() { 43 } 44 45 public ByteArrayOutputStreamExt(int size) { 46 super(size); 47 } 48 49 54 public synchronized int drain(byte[] dest) { 55 int length = Math.min(dest.length, count); 56 if (length > 0) { 57 System.arraycopy(buf, 0, dest, 0, length); 58 for (int i = 0; i < count - length; i++) { 59 buf[i] = buf[i + length]; 60 } 61 count -= length; 62 } 63 return length; 64 } 65 } 66 | Popular Tags |