public static byte[] readBytes(final InputStream ins) throws IOException {
		if (null == ins) throw new IllegalArgumentException("input stream is null");
		byte[] buffer = new byte[BUFFER_SIZE];
		int len = 0;
		BufferedInputStream in = null;
		ByteArrayOutputStream baos = null;

		in = new BufferedInputStream(ins, BUFFER_SIZE);
		baos = new ByteArrayOutputStream();
		try {
			while ((len = in.read(buffer)) > 0) {
				baos.write(buffer, 0, len);
			}
			return baos.toByteArray();
		} catch (IOException e) {
			throw e;
		} catch (Exception e) {
			throw new IOException(e);
		} finally {
			if (null != in) {
				in.close();
				in = null;
			}
			if (null != baos) {
				baos.close();
				baos = null;
			}
		}
	}