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


Java FileTime.to方法代码示例

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


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

示例1: check

import java.nio.file.attribute.FileTime; //导入方法依赖的package包/类
static void check(FileTime mtime, FileTime atime, FileTime ctime,
                  ZipEntry ze, byte[] extra) {
    /*
    System.out.printf("    mtime [%tc]: [%tc]/[%tc]%n",
                      mtime.to(TimeUnit.MILLISECONDS),
                      ze.getTime(),
                      ze.getLastModifiedTime().to(TimeUnit.MILLISECONDS));
     */
    if (mtime.to(TimeUnit.SECONDS) !=
        ze.getLastModifiedTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing mtime failed!");
    if (atime != null &&
        atime.to(TimeUnit.SECONDS) !=
        ze.getLastAccessTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing atime failed!");
    if (ctime != null &&
        ctime.to(TimeUnit.SECONDS) !=
        ze.getCreationTime().to(TimeUnit.SECONDS))
        throw new RuntimeException("Timestamp: storing ctime failed!");
    if (extra != null) {
        // if extra data exists, the current implementation put it at
        // the end of the extra data array (implementation detail)
        byte[] extra1 = ze.getExtra();
        if (extra1 == null || extra1.length < extra.length ||
            !Arrays.equals(Arrays.copyOfRange(extra1,
                                              extra1.length - extra.length,
                                              extra1.length),
                           extra)) {
            throw new RuntimeException("Timestamp: storing extra field failed!");
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:33,代码来源:TestExtraTime.java

示例2: to

import java.nio.file.attribute.FileTime; //导入方法依赖的package包/类
static void to(long v, TimeUnit unit) {
    FileTime t = FileTime.from(v, unit);
    for (TimeUnit u: TimeUnit.values()) {
        long result = t.to(u);
        long expected = u.convert(v, unit);
        if (result != expected) {
            throw new RuntimeException("unexpected result");
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:Basic.java

示例3: assetRequested

import java.nio.file.attribute.FileTime; //导入方法依赖的package包/类
@Override
@FromAnyThread
public synchronized void assetRequested(@NotNull final AssetKey key) {
    if (key.getCacheType() == null) {
        return;
    }

    final String extension = key.getExtension();
    if (StringUtils.isEmpty(extension)) return;

    final ObjectDictionary<String, Reference> table = getAssetCacheTable();
    final Reference reference = table.get(key.getName());
    if (reference == null) return;

    final Path assetFile = getRealFile(Paths.get(key.getName()));
    if (assetFile == null || !Files.exists(assetFile)) return;

    try {

        final long timestamp = reference.getLong();

        final FileTime lastModifiedTime = Files.getLastModifiedTime(assetFile);
        if (lastModifiedTime.to(TimeUnit.MILLISECONDS) <= timestamp) return;

        final Editor editor = Editor.getInstance();
        final AssetManager assetManager = editor.getAssetManager();
        assetManager.deleteFromCache(key);

    } catch (final IOException e) {
        LOGGER.warning(e);
    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:33,代码来源:ResourceManager.java

示例4: fileTimeToWinTime

import java.nio.file.attribute.FileTime; //导入方法依赖的package包/类
/**
 * Converts FileTime to Windows time.
 */
public static final long fileTimeToWinTime(FileTime ftime) {
    return (ftime.to(TimeUnit.MICROSECONDS) - WINDOWS_EPOCH_IN_MICROSECONDS) * 10;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:ZipUtils.java

示例5: fileTimeToUnixTime

import java.nio.file.attribute.FileTime; //导入方法依赖的package包/类
/**
 * Converts FileTime to "standard Unix time".
 */
public static final long fileTimeToUnixTime(FileTime ftime) {
    return ftime.to(TimeUnit.SECONDS);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:ZipUtils.java

示例6: setLastModifiedTime

import java.nio.file.attribute.FileTime; //导入方法依赖的package包/类
/**
 * Sets the last modification time of the entry.
 *
 * <p> When output to a ZIP file or ZIP file formatted output stream
 * the last modification time set by this method will be stored into
 * zip file entry's {@code date and time fields} in {@code standard
 * MS-DOS date and time format}), and the extended timestamp fields
 * in {@code optional extra data} in UTC time.
 *
 * @param  time
 *         The last modification time of the entry
 * @return This zip entry
 *
 * @throws NullPointerException if the {@code time} is null
 *
 * @see #getLastModifiedTime()
 * @since 1.8
 */
public ZipEntry setLastModifiedTime(FileTime time) {
    Objects.requireNonNull(name, "time");
    this.mtime = time;
    this.time = time.to(TimeUnit.MILLISECONDS);
    return this;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:ZipEntry.java

示例7: setLastModifiedTime

import java.nio.file.attribute.FileTime; //导入方法依赖的package包/类
/**
 * Sets the last modification time of the entry.
 *
 * <p> When output to a ZIP file or ZIP file formatted output stream
 * the last modification time set by this method will be stored into
 * zip file entry's {@code date and time fields} in {@code standard
 * MS-DOS date and time format}), and the extended timestamp fields
 * in {@code optional extra data} in UTC time.
 *
 * @param  time
 *         The last modification time of the entry
 * @return This zip entry
 *
 * @throws NullPointerException if the {@code time} is null
 *
 * @see #getLastModifiedTime()
 * @since 1.8
 */
public ZipEntry setLastModifiedTime(FileTime time) {
    Objects.requireNonNull(name, "time");
    this.mtime = time;
    this.time = time.to(TimeUnit.MILLISECONDS);
    this.dostime = -1;
    return this;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:ZipEntry.java


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