Reads a byte array prefixed by its length encoded using vByte.

@param s the stream from which the array should be read.
@return the array.
760469
public final static byte[] readByteArray(final ObjectInputStream s) throws IOException {
		final byte[] a = new byte[readVByte(s)];
		s.readFully(a);
		return a;
	}
1170775
public byte[] getBytes() {
		final int len = getVInt();
		final byte[] bytes = new byte[len];
		System.arraycopy(buf, bufPosition, bytes, 0, bytes.length);
		bufPosition += bytes.length;
		return bytes;
	}
366043
public static byte[] serialize(Serializable s) throws IOException {

        HsqlByteArrayOutputStream bo = new HsqlByteArrayOutputStream();
        ObjectOutputStream        os = new ObjectOutputStream(bo);

        os.writeObject(s);

        return bo.toByteArray();
    }
1306706
public synchronized byte[] readBytes() throws IOException
    {
        final int dataLength = dataInputStream.readInt();
        final byte[] data = new byte[dataLength];

        final int dataRead = dataInputStream.read(data, 0, dataLength);
        if (dataRead != dataLength) throw new IOException("Not enough data available");

        return data;
    }
583204
public static byte[] decode(String s)
    {
        int len = s.length();
        if (len % 2 != 0)
        {
            return null;
        }

        byte[] bytes = new byte[len / 2];
        int pos = 0;

        for (int i = 0; i < len; i += 2)
        {
            byte hi = (byte) Character.digit(s.charAt(i), 16);
            byte lo = (byte) Character.digit(s.charAt(i + 1), 16);
            bytes[pos++] = (byte) (hi * 16 + lo);
        }

        return bytes;
    }
323652
protected long readFromByteArray(OutputStream stream, long length, long position) throws IOException
   {
      byte[] data = getAsByteArray();
      length = validateAndAdjustLenght(length, position, data.length);

      stream.write(data, (int)position, (int)length);

      return length;
   }
334970
public byte []
readByteArray() {
	int len = remaining();
	byte [] out = new byte[len];
	byteBuffer.get(out, 0, len);
	return out;
}
1208330
public static byte[] decode(String s) {
        int delta = s.endsWith( "==" ) ? 2 : s.endsWith( "=" ) ? 1 : 0;
        byte[] buffer = new byte[s.length() * 3 / 4 - delta];
        int mask = 0xFF;
        int index = 0;
        for (int i = 0; i < s.length(); i += 4) {
            int c0 = toInt[s.charAt( i )];
            int c1 = toInt[s.charAt( i + 1)];
            buffer[index++] = (byte)(((c0 << 2) | (c1 >> 4)) & mask);
            if (index >= buffer.length) {
                return buffer;
            }
            int c2 = toInt[s.charAt( i + 2)];
            buffer[index++] = (byte)(((c1 << 4) | (c2 >> 2)) & mask);
            if (index >= buffer.length) {
                return buffer;
            }
            int c3 = toInt[s.charAt( i + 3 )];
            buffer[index++] = (byte)(((c2 << 6) | c3) & mask);
        }
        return buffer;
    }
1294207
public static byte[] readBytes(final BitInput bitInput, final int lengthSize, final boolean byteUnsigned,
                                   final int byteSize)
            throws IOException {
        if (bitInput == null) {
            throw new NullPointerException("bitInput is null");
        }
        requireValidSizeInt(true, lengthSize);
        requireValidSizeByte(byteUnsigned, byteSize);
        final int length = bitInput.readInt(true, lengthSize);
        final byte[] byteArray = new byte[length];
        for (int i = 0; i < byteArray.length; i++) {
            byteArray[i] = bitInput.readByte(byteUnsigned, byteSize);
        }
        return byteArray;
    }
154743
@Override
    public byte[] read(ScanBuffer buffer) {
        int length = getLength(buffer);
        if (length<0) return null;
        return buffer.getBytes(length);
    }
734694
public static final Bytes of(String s) {
    Objects.requireNonNull(s);
    if (s.isEmpty()) {
      return EMPTY;
    }
    byte[] data = s.getBytes(StandardCharsets.UTF_8);
    return new Bytes(data, s);
  }
443978
public static byte[] readStream(InputStream input, int length) throws IOException {
        byte[] bytes = new byte[length];
        int offset = 0;
        while (offset < bytes.length) {
            int bytesRead = input.read(bytes, offset, bytes.length - offset);
            if (bytesRead == -1) {
                break; // end of stream
            }
            offset += bytesRead;
        }
        return bytes;
    }
1267355
private byte[] read(InputStream in) throws IOException {
		ByteArrayOutputStream out = new ByteArrayOutputStream(READ_FILE_BASE_SIZE);
		byte[] buffer = new byte[READ_BUFFER_SIZE];
		int count = in.read(buffer);
		while (count != -1) {
			if (count != 0) {
				out.write(buffer, 0, count);
			}
			count = in.read(buffer);
		}
		in.close();
		return out.toByteArray();
	}
1010018
public static byte[] toNullTerminatedFixedSizeByteArray(String s, int length) {
        if (s.length() >= length) {
            s = s.substring(0, length - 1);
        }
        while (s.length() < length) {
            s += '\0';
        }
        return s.getBytes();
    }
1087503
public static byte[] readAllToBytes(final InputStream in) throws IOException {
    try {
      final ByteArrayOutputStream result = new ByteArrayOutputStream();
      final byte[] buffer = new byte[1024];
      int length;
      while ((length = in.read(buffer)) != -1) {
        result.write(buffer, 0, length);
      }
      return result.toByteArray();
    } finally {
      in.close();
    }
  }
728237
public static byte[] toByteArray(InputStream is) throws IOException {
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        try {
            byte[] b = new byte[BUFFER_SIZE];
            int n = 0;
            while ((n = is.read(b)) != -1) {
                output.write(b, 0, n);
            }
            return output.toByteArray();
        } finally {
            output.close();
        }
    }
270088
public static byte[] chars2Bytes(final char[] chars) {
        if (chars == null || chars.length <= 0) return null;
        int    len   = chars.length;
        byte[] bytes = new byte[len];
        for (int i = 0; i < len; i++) {
            bytes[i] = (byte) (chars[i]);
        }
        return bytes;
    }