Wrap the original stream in a BufferedInputStream, then wrap that in a GZipInputStream.
Next try to extract a ZipEntry. If this works, it's a zip file. Then you can use "mark" and "reset" in the BufferedInputStream to return to the initial position in the stream, after your check.