package com.uas.report.axis.util;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class StreamUtil {

	private static final int READ_STREAM_BUFFER_SIZE = 10000;

	public static byte[] readData(InputStream is) throws IOException {
		if (is == null) {
			return null;
		}

		ByteArrayOutputStream baos = new ByteArrayOutputStream();

		byte[] bytes = new byte[READ_STREAM_BUFFER_SIZE];
		int ln = 0;
		while ((ln = is.read(bytes)) > 0) {
			baos.write(bytes, 0, ln);
		}

		return baos.toByteArray();
	}
}
