Code example for PushbackInputStream

Methods: read, unread

0
	public InputStream encapsulateGZipOnNeed(InputStream input) throws IOException
	{ 
		InputStream output = input;
		byte[] magic = new byte[2];
		 
		PushbackInputStream pb = new PushbackInputStream(input,2);
		pb.read(magic, 0, 2);
		pb.unread(magic);
		 
		if(magic[0] == (byte) 0x1f && magic[1] == (byte) 0x8b) {
			/* GZIP is added round PushBackInputStream else we'll miss 2 bytes */ 
			output = new GZIPInputStream(pb);
		} else { 
			output = pb;
		} 
		return output;
	} 
	 
	@SuppressLint("SetJavaScriptEnabled") 
	public RelativeLayout injectAdvertisement(Context context, View child)
	{