是否为jar文件

@param file 文件
@return 是否为jar文件
@since 4.4.2
325615
private static boolean isJarFile(File file) {
		if (false == FileUtil.isFile(file)) {
			return false;
		}
		return file.getPath().toLowerCase().endsWith(".jar");
	}
1316214
public static String getFileExtension(File file) {
        if (file == null) {
            return null;
        }

        String fileName = file.getName();
        int dotPos = fileName.lastIndexOf('.');
        return dotPos == -1 ? null : fileName.substring(dotPos + 1);
    }
1320667
public static boolean isJarFile(Path path) {
        return Files.isRegularFile(path) && path.toString().toLowerCase().endsWith(".jar");
    }
175683
private static File toJar(final File file) throws IOException {
    final File tempFolder = Files.createTempDirectory("reef-tmp-tempFolder").toFile();
    final File jarFile = File.createTempFile(file.getCanonicalFile().getName(), ".jar", tempFolder);
    LOG.log(Level.FINEST, "Adding contents of folder {0} to {1}", new Object[]{file, jarFile});
    try (final JARFileMaker jarMaker = new JARFileMaker(jarFile)) {
      jarMaker.addChildren(file);
    }
    return jarFile;
  }
997957
public Jar setJarPrefix(Path file) {
        verifyNotSealed();
        if (jos != null)
            throw new IllegalStateException("Really executable cannot be set after entries are added.");
        if (file != null && jarPrefixStr != null)
            throw new IllegalStateException("A prefix has already been set (" + jarPrefixStr + ")");
        this.jarPrefixFile = file;
        return this;
    }
634310
public static boolean jreFile(final File file) {
        final String javaHome = System.getProperty("java.home");
        try {
            return file.getCanonicalPath().startsWith(javaHome) && file.isFile();
        } catch (final IOException ex) {
            throw new RuntimeException("Error reading canonical path for: " + file, ex);
        }
    }
1117640
static String readFileFromJarfile(String fulljarpath) throws IOException {
        assert (fulljarpath.contains(".jar!"));

        String[] paths = fulljarpath.split("!");
        if (paths[0].startsWith("file:"))
            paths[0] = paths[0].substring("file:".length());
        paths[1] = paths[1].substring(1);

        return readFileFromJarfile(paths[0], paths[1]);
    }
1323972
public FileInputStream getFileInputStream(final File file) throws FileNotFoundException {
        if (System.getSecurityManager() == null)
            return new FileInputStream(file);
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<FileInputStream>() {
                @Override
                public FileInputStream run() throws FileNotFoundException {
                    return new FileInputStream(file);
                }
            }, controlContext);
        } catch (PrivilegedActionException e) {
            if (e.getException() instanceof FileNotFoundException)
                throw (FileNotFoundException) e.getException();
            throw (RuntimeException) e.getException();
        }
    }
374081
public static String file(File file) throws IOException {
        FileInputStream fi = null;
        try {
            fi = new FileInputStream(file);
            return stream(fi, file.length());
        } finally {
            if (fi != null) {
                try {
                    fi.close();
                } catch (Throwable t) {
                }
            }
        }

    }
1320142
public static Source source(File file) throws FileNotFoundException {
    if (file == null) throw new IllegalArgumentException("file == null");
    return source(new FileInputStream(file));
  }
274582
public String readFile(String fileName, String jarName)
    {
        File file = null;
        BufferedReader reader = null;
        InputStream inputStream = null;
        StringBuilder builder = new StringBuilder();
        try
        {
            file = new File(fileName);

            // When we run this program from Eclipse, it doesnt need the Code
            // described below.
            // But when it is being run as a JAR File, then we cannot specify a
            // PATH as the files are located in the JAR
            // Hence this !file.exists allows us to
            if (!file.exists())
            {
                Log.logInfo("No file: Will try retirieving using JarFile Logic for " + fileName);
                JarFile jarFile = new JarFile(jarName);
                Log.logInfo("file for reading: " + jarFile.getName());
                JarEntry jarEntry = jarFile.getJarEntry(fileName);
                inputStream = jarFile.getInputStream(jarEntry);
                byte[] b = new byte[8092];
                int n = 0;
                while ((n = inputStream.read(b)) > 0)
                {
                    for (int i = 0; i < b.length; i++)
                    {
                        builder.append((char) b[i]);
                    }
                }
            }
            else
            {
                Log.logInfo("file for reading: " + file.getAbsolutePath());
                reader = new BufferedReader(new FileReader(file));

                String inputLine = "";
                while ((inputLine = reader.readLine()) != null)
                {
                    builder.append(inputLine);
                }
            }
        }

        catch (Exception e)
        {
            Log.logInfo("File not found.");
            e.printStackTrace();
        }

        finally
        {
            try
            {
                if (reader != null) reader.close();
                if (inputStream != null) inputStream.close();

            }

            catch (IOException e)
            {
                e.printStackTrace();
            }
        }
        return builder.toString();
    }
97625
public static String getFileExtension(File file) {
		return com.google.common.io.Files.getFileExtension(file.getName());
	}
877873
public static boolean unpackJar (JarFile jar, File target)
    {
        boolean failure = false;
        Enumeration<?> entries = jar.entries();
        while (!failure && entries.hasMoreElements()) {
            JarEntry entry = (JarEntry)entries.nextElement();
            File efile = new File(target, entry.getName());

            // if we're unpacking a normal jar file, it will have special path
            // entries that allow us to create our directories first
            if (entry.isDirectory()) {
                if (!efile.exists() && !efile.mkdir()) {
                    log.warning("Failed to create jar entry path", "jar", jar, "entry", entry);
                }
                continue;
            }

            // but some do not, so we want to ensure that our directories exist
            // prior to getting down and funky
            File parent = new File(efile.getParent());
            if (!parent.exists() && !parent.mkdirs()) {
                log.warning("Failed to create jar entry parent", "jar", jar, "parent", parent);
                continue;
            }

            BufferedOutputStream fout = null;
            InputStream jin = null;
            try {
                fout = new BufferedOutputStream(new FileOutputStream(efile));
                jin = jar.getInputStream(entry);
                StreamUtil.copy(jin, fout);
            } catch (Exception e) {
                log.warning("Failure unpacking", "jar", jar, "entry", efile, "error", e);
                failure = true;
            } finally {
                StreamUtil.close(jin);
                StreamUtil.close(fout);
            }
        }

        try {
            jar.close();
        } catch (Exception e) {
            log.warning("Failed to close jar file", "jar", jar, "error", e);
        }

        return !failure;
    }
109442
protected String resolveJarFile() {
        Class resourceClass = resourceInfo.getResourceClass();
        if (resourceClass == null) return null;
        String classFile = resourceClass.getName().replace(".", "/") + ".class";
        URL classUrl = IOUtils.getResource(classFile);
        String urlProtocol = classUrl.getProtocol();
        if (urlProtocol.equals("jar")) {
            String path = classUrl.getPath();
            return path.substring(0, path.length() - classFile.length() - 1);
        }
        return null;
    }
761897
private static List<File> loopJar(File file) {
		return FileUtil.loopFiles(file, new FileFilter() {
			@Override
			public boolean accept(File file) {
				return isJarFile(file);
			}
		});
	}
116810
private void findJarFile() throws IOException {
        if (getUseCaches()) {
            synchronized (jarCache) {
                jarFile = jarCache.get(jarFileURL);
            }
            if (jarFile == null) {
                JarFile jar = openJarFile();
                synchronized (jarCache) {
                    jarFile = jarCache.get(jarFileURL);
                    if (jarFile == null) {
                        jarCache.put(jarFileURL, jar);
                        jarFile = jar;
                    } else {
                        jar.close();
                    }
                }
            }
        } else {
            jarFile = openJarFile();
        }

        if (jarFile == null) {
            throw new IOException();
        }
    }
271073
public static String getExtension(String file)
    {
        Check.notNull(file);

        String ext = Constant.EMPTY_STRING;
        final int i = file.lastIndexOf(Constant.DOT);
        if (i >= 0 && i < file.length() - 1)
        {
            ext = file.substring(i + 1).toLowerCase(Locale.ENGLISH);
        }
        return ext;
    }