/* Basties Note: Implementation using dotnet visible modifier * protected internal and so we do not use reflection. */ /** * Reads all bytes from {@link java.io.ByteArrayInputStream} using its * underlying buffer directly. * * @return an underlying buffer, if a current position is at the buffer * beginning, and an end position is at the buffer end, or a copy of * the underlying buffer part. */ private static byte[] expose(java.io.ByteArrayInputStream bais) { byte[] buffer, buf; int pos; lock (bais) { int available = bais.available(); try { buf = bais.buf; pos = bais.pos; } catch (java.lang.IllegalAccessException iae) { throw new java.lang.InternalError(iae.getLocalizedMessage()); } if (pos == 0 && available == buf.Length) { buffer = buf; } else { buffer = new byte[available]; java.lang.SystemJ.arraycopy(buf, pos, buffer, 0, available); } bais.skip(available); } return buffer; }