Here you can find the source of isZip(File file)
public static boolean isZip(File file)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010 - 2011 Red Hat, Inc. * Distributed under license by Red Hat, Inc. All rights reserved. * This program is 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 * /*from w ww .j a v a 2s .c om*/ * Contributors: * Red Hat, Inc. - initial API and implementation ******************************************************************************/ import java.io.BufferedInputStream; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Main { public static boolean isZip(File file) { if (file.isDirectory()) { return false; } if (!file.canRead()) { return false; } if (file.length() < 4) { return false; } try { DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file))); int test = in.readInt(); in.close(); return test == 0x504b0304; } catch (IOException ioe) { return false; } } }