当前位置: 首页>>代码示例>>Java>>正文


Java JarEntry.getTime方法代码示例

本文整理汇总了Java中java.util.jar.JarEntry.getTime方法的典型用法代码示例。如果您正苦于以下问题:Java JarEntry.getTime方法的具体用法?Java JarEntry.getTime怎么用?Java JarEntry.getTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.jar.JarEntry的用法示例。


在下文中一共展示了JarEntry.getTime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyStream

import java.util.jar.JarEntry; //导入方法依赖的package包/类
private void copyStream(InputStream inputStream, JarOutputStream jos, JarEntry ze, String pathName) {
    try {

        ZipEntry newEntry = new ZipEntry(pathName);
        // Make sure there is date and time set.
        if (ze.getTime() != -1) {
            newEntry.setTime(ze.getTime());
            newEntry.setCrc(ze.getCrc()); // If found set it into output file.
        }
        jos.putNextEntry(newEntry);
        IOUtils.copy(inputStream, jos);
        IOUtils.closeQuietly(inputStream);
    } catch (Exception e) {
        //throw new GradleException("copy stream exception", e);
        //e.printStackTrace();
        logger.error("copy stream exception >>> " + pathName + " >>>" + e.getMessage());
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:19,代码来源:JarRefactor.java

示例2: run

import java.util.jar.JarEntry; //导入方法依赖的package包/类
void run() throws Exception {
    RelativeFile TEST_ENTRY_NAME = new RelativeFile("java/lang/String.class");

    File testJar = createJar("test.jar", "java.lang.*");

    try (JarFile j = new JarFile(testJar)) {
        JarEntry je = j.getJarEntry(TEST_ENTRY_NAME.getPath());
        long jarEntryTime = je.getTime();

        Context context = new Context();
        JavacFileManager fm = new JavacFileManager(context, false, null);
        fm.setLocation(StandardLocation.CLASS_PATH, Collections.singletonList(testJar));
        FileObject fo =
            fm.getFileForInput(StandardLocation.CLASS_PATH, "", TEST_ENTRY_NAME.getPath());
        long jfoTime = fo.getLastModified();

        check(je, jarEntryTime, fo, jfoTime);

        if (errors > 0)
            throw new Exception(errors + " occurred");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:T6725036.java

示例3: urlLastModified

import java.util.jar.JarEntry; //导入方法依赖的package包/类
public static long urlLastModified(URL url) throws URISyntaxException, IOException {
    url = osgiToJar(url);
    if ("jar".equalsIgnoreCase(url.getProtocol())) {
        JarURLConnection jarEntryConn = (JarURLConnection)url.openConnection();
        // Check that the jar file actually exists on the file system
        File file = new File(jarEntryConn.getJarFileURL().getPath());
        if (!file.exists()) throw new IOException("Unable to process JAR url. JAR file is missing: " + file);
        try (JarFile jarFile = new JarFile(file)) {
            // Automatically reject any JAR URL which does not contain a JAR entry
            String jarEntryName = jarEntryConn.getEntryName();
            if (jarEntryName == null) throw new IOException("Unsupported JAR url. Missing JAR entry: " + url);
            JarEntry jarEntry = jarFile.getJarEntry(jarEntryName);
            return jarEntry != null ? jarEntry.getTime() : -1;
        }
     }

    return new File(url.toURI()).lastModified();
}
 
开发者ID:salesforce,项目名称:grammaticus,代码行数:19,代码来源:I18nJavaUtil.java


注:本文中的java.util.jar.JarEntry.getTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。