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


Java ZipEntry.getTime方法代码示例

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


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

示例1: unpackZip

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
private static void unpackZip(ZipFile zipFile, File unpackDir) throws IOException {
    Enumeration<? extends ZipEntry> entries = zipFile.entries();
    while (entries.hasMoreElements()) {
        ZipEntry entry = entries.nextElement();
        File destination = new File(unpackDir.getAbsolutePath() + "/" + entry.getName());
        if (entry.isDirectory()) {
            destination.mkdirs();
        } else {
            destination.getParentFile().mkdirs();
            FileCopyUtils.copy(zipFile.getInputStream(entry), new FileOutputStream(destination));
        }
        if (entry.getTime() != -1) {
            destination.setLastModified(entry.getTime());
        }
    }
}
 
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:17,代码来源:SampleProjects.java

示例2: testTimeConversions

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
static void testTimeConversions(long from, long to, long step) {
    ZipEntry ze = new ZipEntry("TestExtraTime.java");
    for (long time = from; time <= to; time += step) {
        ze.setTime(time);
        FileTime lastModifiedTime = ze.getLastModifiedTime();
        if (lastModifiedTime.toMillis() != time) {
            throw new RuntimeException("setTime should make getLastModifiedTime " +
                    "return the specified instant: " + time +
                    " got: " + lastModifiedTime.toMillis());
        }
        if (ze.getTime() != time) {
            throw new RuntimeException("getTime after setTime, expected: " +
                    time + " got: " + ze.getTime());
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:TestExtraTime.java

示例3: ZipFile2

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
public ZipFile2(String zipPath, ZipEntry entry) {
    if (entry == null)
        throw new IllegalArgumentException("file must not be null");
    if(!zipPath.endsWith("/"))
        zipPath += "/";
   
    mPath = zipPath+entry.getName();
    mLength = entry.getSize();
    mIsFile = !entry.isDirectory();
    mLastModified = entry.getTime();
}
 
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:12,代码来源:ZipFile2.java

示例4: unzip

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
/**
 * @source http://stackoverflow.com/a/27050680
 */
public static void unzip(InputStream zipFile, File targetDirectory) throws Exception {
    ZipInputStream in = new ZipInputStream(new BufferedInputStream(zipFile));
    try {
        ZipEntry ze;
        int count;
        byte[] buffer = new byte[8192];
        while ((ze = in.getNextEntry()) != null) {
            File file = new File(targetDirectory, ze.getName());
            File dir = ze.isDirectory() ? file : file.getParentFile();
            if (!dir.isDirectory() && !dir.mkdirs()) {
                throw new Exception("Failed to ensure directory: " + dir.getAbsolutePath());
            }
            if (ze.isDirectory()) {
                continue;
            }
            BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
            try {
                while ((count = in.read(buffer)) != -1)
                    out.write(buffer, 0, count);
            } finally {
                out.close();
            }
            long time = ze.getTime();
            if (time > 0) {
                file.setLastModified(time);
            }
        }
    } finally {
        in.close();
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:35,代码来源:Util.java

示例5: zeString

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
static String zeString(ZipEntry ze) {
    int store = (ze.getCompressedSize() > 0) ?
        (int)( (1.0 - ((double)ze.getCompressedSize()/(double)ze.getSize()))*100 )
        : 0 ;
    // Follow unzip -lv output
    return ze.getSize() + "\t" + ze.getMethod()
        + "\t" + ze.getCompressedSize() + "\t"
        + store + "%\t"
        + new Date(ze.getTime()) + "\t"
        + Long.toHexString(ze.getCrc()) + "\t"
        + ze.getName() ;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:Utils.java

示例6: getBuildDateAsString

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
/**
 * INTERNAL method that returns the build date of the current APK as a string, or null if unable to determine it.
 *
 * @param context    A valid context. Must not be null.
 * @param dateFormat DateFormat to use to convert from Date to String
 * @return The formatted date, or "Unknown" if unable to determine it.
 */
private static String getBuildDateAsString(Context context, DateFormat dateFormat) {
    String buildDate;
    try {
        ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), 0);
        ZipFile zf = new ZipFile(ai.sourceDir);
        ZipEntry ze = zf.getEntry("classes.dex");
        long time = ze.getTime();
        buildDate = dateFormat.format(new Date(time));
        zf.close();
    } catch (Exception e) {
        buildDate = "Unknown";
    }
    return buildDate;
}
 
开发者ID:tututututututu,项目名称:BaseCore,代码行数:22,代码来源:CrashHander.java

示例7: getAllJarConfigs

import java.util.zip.ZipEntry; //导入方法依赖的package包/类
private List<ConfigFile> getAllJarConfigs(final String[] suffixes) throws IOException {

        List<ConfigFile> configs = new ArrayList<>();
        String metaPath = "META-INF";
        Enumeration<URL> urls = Thread.currentThread().getContextClassLoader().getResources(metaPath);

        while (urls.hasMoreElements()) {
            URL url = urls.nextElement();
            if (url != null && "jar".equals(url.getProtocol())) {
                String urlStr = url.toString();
                String location = urlStr.substring(urlStr.indexOf('f'), urlStr.lastIndexOf('!'));
                String jarName = location.substring(location.lastIndexOf('/')+1, location.length());

                URL realUrl = new URL(location);
                try (ZipInputStream zip = new ZipInputStream(realUrl.openStream())) {
                    ZipEntry ze;
                    while ((ze = zip.getNextEntry()) != null) {

                        boolean canAdd = false;
                        String zeNameLowerCase = ze.getName().toLowerCase();

                        /*
                        if(zeNameLowerCase.endsWith("pom.xml") || zeNameLowerCase.endsWith("pom.properties")){
                            continue;
                        }*/

                        for (String suf : suffixes) {
                           if(zeNameLowerCase.endsWith("." + suf)) {
                              canAdd = true;
                               break;
                           }
                        }

                        if(canAdd) {

                            ConfigFile configFile = new ConfigFile();
                            configFile.lastModified = ze.getTime();
                            configFile.size = ze.getSize();
                            configFile.name = jarName + "!/" + ze.getName();
                            configFile.path = location + "!/" + ze.getName();
                            configs.add(configFile);
                        }

                    }

                } catch (Throwable e) {
                    logger.warn("get jar maven pom failed! location:" + location, e);
                }
            }
        }

        return configs;
    }
 
开发者ID:ctripcorp,项目名称:cornerstone,代码行数:54,代码来源:AllConfigFiles.java


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