Here you can find the source of isZipName(URI documentIRI, URLConnection connection)
private static boolean isZipName(URI documentIRI, URLConnection connection)
//package com.java2s; //License from project: Open Source License import java.net.URI; import java.net.URLConnection; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static final String ZIP_FILE_EXTENSION = ".zip"; private static final String CONTENT_DISPOSITION_HEADER = "Content-Disposition"; private static final Pattern CONTENT_DISPOSITION_FILE_NAME_PATTERN = Pattern .compile(".*filename=\"([^\\s;]*)\".*"); private static final int CONTENT_DISPOSITION_FILE_NAME_PATTERN_GROUP = 1; private static boolean isZipName(URI documentIRI, URLConnection connection) { if (isZipFileName(documentIRI.toString())) { return true; } else {/* w w w . j a va 2 s . com*/ String fileName = getFileNameFromContentDisposition(connection); return fileName != null && isZipFileName(fileName); } } private static boolean isZipFileName(String fileName) { return fileName.toLowerCase().endsWith(ZIP_FILE_EXTENSION); } private static String getFileNameFromContentDisposition(URLConnection connection) { String contentDispositionHeaderValue = connection.getHeaderField(CONTENT_DISPOSITION_HEADER); if (contentDispositionHeaderValue != null) { Matcher matcher = CONTENT_DISPOSITION_FILE_NAME_PATTERN.matcher(contentDispositionHeaderValue); if (matcher.matches()) { return matcher.group(CONTENT_DISPOSITION_FILE_NAME_PATTERN_GROUP); } } return null; } }