public static byte[] inflate(byte data[],boolean noWrap) 
    { 
        if(data.length == 0) 
            return data; 
        ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length); 
        
        Inflater inflater = new Inflater(noWrap);
        boolean isDeflated = true;

        inflater.reset(); 
        inflater.setInput(data); 
        byte buf[] = new byte[1024];
            
        while(!inflater.finished() && isDeflated)  
        try 
        { 
        	int count = inflater.inflate(buf); 
            bos.write(buf, 0, count); 
        } 
        catch(DataFormatException e) 
        { 
        	isDeflated = false;
        } 
        finally 
        { 
            try
            {
            	bos.close();
            }
            catch(IOException e) 
            { 
           	 	System.out.print("IOException: " + e.getMessage()); 
            }
        } 
         
        if (!isDeflated)
        	return data;
        else
        {
        	return bos.toByteArray();
        }
    }