--------------------------------------------------------------------- byteArrayOutputStream ---------------------------------------------------------------------
183206
function() {

    var _bytes = [];

    var _this = {};

    _this.writeByte = function(b) {
      _bytes.push(b & 0xff);
    };

    _this.writeShort = function(i) {
      _this.writeByte(i);
      _this.writeByte(i >>> 8);
    };

    _this.writeBytes = function(b, off, len) {
      off = off || 0;
      len = len || b.length;
      for (var i = 0; i < len; i += 1) {
        _this.writeByte(b[i + off]);
      }
    };

    _this.writeString = function(s) {
      for (var i = 0; i < s.length; i += 1) {
        _this.writeByte(s.charCodeAt(i) );
      }
    };

    _this.toByteArray = function() {
      return _bytes;
    };

    _this.toString = function() {
      var s = '';
      s += '[';
      for (var i = 0; i < _bytes.length; i += 1) {
        if (i > 0) {
          s += ',';
        }
        s += _bytes[i];
      }
      s += ']';
      return s;
    };

    return _this;
  }
940639
@Override
    public byte[] asBytes() throws IOException {
        try (ServletInputStream stream = request.getInputStream()) {
            ByteArrayOutputStream array = new ByteArrayOutputStream(stream.available());
            return array.toByteArray();
        }
    }
1142410
public InputStream toInputStream() {
        
        String text = toXml();
        return new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8));
        
    }
114168
static private void encodeBytes(byte previous, byte current, int byteIndex, StringBuilder output) {
        int chunk;
        int offset = byteIndex % 5;
        switch (offset) {
            case 0:
                chunk = ((current & 0xF8) >>> 3);
                output.append(lookupTable.charAt(chunk));
                break;
            case 1:
                chunk = (((previous & 0x07) << 2) | ((current & 0xC0) >>> 6));
                output.append(lookupTable.charAt(chunk));
                chunk = ((current & 0x3E) >>> 1);
                output.append(lookupTable.charAt(chunk));
                break;
            case 2:
                chunk = (((previous & 0x01) << 4) | ((current & 0xF0) >>> 4));
                output.append(lookupTable.charAt(chunk));
                break;
            case 3:
                chunk = (((previous & 0x0F) << 1) | ((current & 0x80) >>> 7));
                output.append(lookupTable.charAt(chunk));
                chunk = ((current & 0x7C) >>> 2);
                output.append(lookupTable.charAt(chunk));
                break;
            case 4:
                chunk = (((previous & 0x03) << 3) | ((current & 0xE0) >>> 5));
                output.append(lookupTable.charAt(chunk));
                chunk = (current & 0x1F);
                output.append(lookupTable.charAt(chunk));
                break;
        }
    }
513847
public final static void writeByteArray(final byte[] a, final ObjectOutputStream s) throws IOException {
		writeVByte(a.length, s);
		s.write(a);
	}
478544
private static byte[] preload(InputStream stream) throws IOException {
        byte[] buf = new byte[4096];
        ByteArrayOutputStream preloaded = new ByteArrayOutputStream();

        int read;
        while((read = stream.read(buf)) != -1) {
            preloaded.write(buf, 0, read);
        }

        return preloaded.toByteArray();
    }
1111536
public static byte[] streamBytes(InputStream stream) throws IOException {

		ByteArrayOutputStream bytes = new ByteArrayOutputStream();

		copyStream(stream, bytes);

		return bytes.toByteArray();
	}
977929
@Override
	public ByteArrayList fromStream(final InputStream is) throws IOException {
		final int length = Util.readVByte(is);
		buffer.size(length);
		final int actual = is.read(buffer.elements(), 0, length);
		if (actual != length) throw new IOException("Asked for " + length + " but got " + actual);
		return buffer;
	}
877980
public static byte[] inputStreamAsByteArray(InputStream inputStream) {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    try {
      byte[] buffer = new byte[16 * 1024];
      int read;
      while((read = inputStream.read(buffer)) > 0) {
        os.write(buffer, 0, read);
      }
      return os.toByteArray();
    } catch (IOException e) {
      throw LOG.unableToReadInputStream(e);
    }
    finally {
      closeSilently(inputStream);
    }
  }
982109
@Override
  void writeStreamBlob(OutputStream os, 
                       byte[] buffer, int rowOffset,
                       byte []blobBuffer,
                       PageServiceImpl tableService)
    throws IOException
  {
    int offset = rowOffset + offset();
    
    int blobLen = BitsUtil.readInt16(buffer, offset + 2);
    int blobOffset = BitsUtil.readInt16(buffer, offset);
    
    if (blobLen == 0) {
      BitsUtil.writeInt(os, 0);
      return;
    }
    
    if (isLargeBlob(blobLen)) {
      int blobId = BitsUtil.readInt(blobBuffer, blobOffset);
      
      ArrayList<PageBlob> blobList = new ArrayList<>();

      while (blobId > 0) {
        PageBlob page = tableService.getBlobPage(blobId);
        
        blobList.add(page);
        
        blobId = page.getNextId();
      }
        
      for (int i = 0; i < blobList.size(); i++) {
        PageBlob page = blobList.get(i);
        int length = page.getLength();
        
        if ((length & 0xc000_0000) != 0) {
          throw new IllegalStateException(L.l("Unexpected blob length {0} for {1}", 
                                              length, page));
        }
        
        if (i + 1 < blobList.size()) {
          length |= BLOB_CONT_MASK;
        }
        
        BitsUtil.writeInt(os, length);
        
        page.writeToStream(os);
      }
    }
    else {
      BitsUtil.writeInt(os, blobLen);
      
      os.write(blobBuffer, blobOffset, blobLen);
    }
  }
1023893
ByteArrayInputStream getExportStream() {

        Map<CmsUUID, CmsUser> exportUsers = getUserToExport();

        StringBuffer buffer = new StringBuffer();
        CmsUserExportSettings settings = OpenCms.getImportExportManager().getUserExportSettings();

        String separator = CmsStringUtil.substitute(settings.getSeparator(), "\\t", "\t");
        List<String> values = settings.getColumns();

        buffer.append("name");
        Iterator<String> itValues = values.iterator();
        while (itValues.hasNext()) {
            String colName = itValues.next();
            if (isColumnExportable(colName)) {
                buffer.append(separator);
                buffer.append(colName);
            }
        }
        buffer.append("\n");

        Object[] users = exportUsers.values().toArray();

        for (int i = 0; i < users.length; i++) {
            CmsUser exportUser = (CmsUser)users[i];
            if (!isExportable(exportUser)) {
                continue;
            }
            buffer.append(exportUser.getSimpleName());
            itValues = values.iterator();
            while (itValues.hasNext()) {
                buffer.append(separator);
                String curValue = itValues.next();
                if (isColumnExportable(curValue)) {
                    try {
                        Method method = CmsUser.class.getMethod(
                            "get" + curValue.substring(0, 1).toUpperCase() + curValue.substring(1));
                        String curOutput = (String)method.invoke(exportUser);
                        if (CmsStringUtil.isEmptyOrWhitespaceOnly(curOutput) || curOutput.equals("null")) {
                            curOutput = (String)exportUser.getAdditionalInfo(curValue);
                        }

                        if (curValue.equals("password")) {
                            curOutput = OpenCms.getPasswordHandler().getDigestType() + "_" + curOutput;
                        }

                        if (!CmsStringUtil.isEmptyOrWhitespaceOnly(curOutput) && !curOutput.equals("null")) {
                            buffer.append(curOutput);
                        }
                    } catch (NoSuchMethodException e) {
                        Object obj = exportUser.getAdditionalInfo(curValue);
                        if (obj != null) {
                            String curOutput = String.valueOf(obj);
                            if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(curOutput)) {
                                buffer.append(curOutput);
                            }
                        }
                    } catch (IllegalAccessException e) {
                        //
                    } catch (InvocationTargetException e) {
                        //
                    }
                }
            }
            buffer.append("\n");

        }
        return new ByteArrayInputStream(buffer.toString().getBytes());
    }
1225245
public static byte[] readBytes(InputStream is) throws IOException {
        if (is == null) {
            return null;
        }
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        copyStream(is, baos);
        return baos.toByteArray();
    }
432365
public static byte[] readStream(InputStream in) {
        if(in == null){
            return null;
        }
        ByteArrayOutputStream out = null;
        try {
            out = new ByteArrayOutputStream();
            byte[] buf = new byte[1024 * 8];
            int length = 0;
            while((length = in.read(buf)) != -1){
                out.write(buf, 0, length);
            }
            return out.toByteArray();

        } catch (IOException e) {
            throw new IORuntimeException(e);

        } finally {
            closeQuietly(in);
            closeQuietly(out);
        }
    }
415280
static private String convertByteArrToString(byte[] byteArr) {
    StringBuilder sb = new StringBuilder();
    for (byte b : byteArr) {
      int i = b;
      i = i & 0xff;
      sb.append(String.format("%02x", i));
    }
    return sb.toString();
  }
253987
public static byte[] inputStreamToBytes(InputStream in)
    {
        try
        {
            FastByteArrayOutputStream out = new FastByteArrayOutputStream(16384);
            transfer(in, out);
            return Arrays.copyOf(out.buffer, out.size);
        }
        catch (Exception e)
        {
            return null;
        }
    }
788634
public void writeTo(OutputStream out) throws IOException
    {
        int sz=size();

        if (sz<=AJP13ResponsePacket.__MAX_BUF)
            super.writeTo(out);
        else
        {
            int offset=preReserve();
            int data=sz-AJP13ResponsePacket.__DATA_HDR;

            while (data>AJP13ResponsePacket.__MAX_DATA)
            {
                _packet.setDataSize(AJP13ResponsePacket.__MAX_BUF-AJP13ResponsePacket.__HDR_SIZE);
                if (offset>0)
                    System.arraycopy(_buf,0,_buf,offset,AJP13ResponsePacket.__DATA_HDR);
                out.write(_buf,offset,AJP13ResponsePacket.__MAX_BUF);

                data-=AJP13ResponsePacket.__MAX_DATA;
                offset+=AJP13ResponsePacket.__MAX_DATA;
            }

            int len=data+AJP13ResponsePacket.__DATA_HDR;
            _packet.setDataSize(len-AJP13ResponsePacket.__HDR_SIZE);
            if (offset>0)
                System.arraycopy(_buf,0,_buf,offset,AJP13ResponsePacket.__DATA_HDR);
            out.write(_buf,offset,len);
        }
    }
1060903
public void encode(byte aBuffer[], OutputStream aStream)
    throws IOException {
        ByteArrayInputStream inStream = new ByteArrayInputStream(aBuffer);
        encode(inStream, aStream);
    }