Here you can find the source of isZipFile(String fileName)
Parameter | Description |
---|---|
fileName | file to test |
public static boolean isZipFile(String fileName)
//package com.java2s; // %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt import java.io.IOException; import java.util.zip.ZipFile; public class Main { /**/*w w w. j ava2 s .c om*/ * Determine whether the file with the given filename is in .zip or .jar format. * * @param fileName file to test * @return true if the file is in tar format */ public static boolean isZipFile(String fileName) { if (fileName == null || fileName.trim().length() == 0) { return false; } ZipFile zipFile = null; try { zipFile = new ZipFile(fileName.trim()); } catch (IOException ioException) { return false; } finally { if (zipFile != null) { try { zipFile.close(); } catch (IOException e) { // ignore } } } return true; } }