public static byte[] InputStreamToByte(InputStream in)
	{
		int BUFFER_SIZE = 4096;
		ByteArrayOutputStream outStream = null;
		byte[] data = new byte[4096];
		int count = -1;
		
		try
		{
			outStream = new ByteArrayOutputStream();
			while ((count = in.read(data, 0, BUFFER_SIZE)) != -1)
			{
				outStream.write(data, 0, count);
			}
				
			return outStream.toByteArray();
		}
		catch (IOException e)
		{
			e.printStackTrace();
			return null;
		}
		finally
		{
			if (null != outStream)
			{
				try
				{
					outStream.close();
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
		}
	}