當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。