The DeflaterOutputStream and InflaterInputStream classes provide mechanism to compress and uncompress the data in the deflate compression format. DeflaterOutputStream class: The DeflaterOutputStream class is used…