Here you can find the source of isZipFile(String path)
public static boolean isZipFile(String path)
//package com.java2s; /******************************************************************************* * Copyright (c) 2016 Chen Chao(cnfree2000@hotmail.com). * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:// w w w . java2s .co m * Chen Chao - initial API and implementation *******************************************************************************/ import java.io.IOException; import java.util.zip.ZipFile; public class Main { public static boolean isZipFile(String path) { if (path == null) return false; try { new ZipFile(path).close(); ; return true; } catch (IOException e) { return false; } } }