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


Java FileTime.equals方法代码示例

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


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

示例1: eq

import java.nio.file.attribute.FileTime; //导入方法依赖的package包/类
static void eq(long v1, TimeUnit u1, long v2, TimeUnit u2) {
    FileTime t1 = FileTime.from(v1, u1);
    FileTime t2 = FileTime.from(v2, u2);
    if (!t1.equals(t2))
        throw new RuntimeException("not equal");
    if (t1.hashCode() != t2.hashCode())
        throw new RuntimeException("hashCodes should be equal");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:Basic.java

示例2: neq

import java.nio.file.attribute.FileTime; //导入方法依赖的package包/类
static void neq(long v1, TimeUnit u1, long v2, TimeUnit u2) {
    FileTime t1 = FileTime.from(v1, u1);
    FileTime t2 = FileTime.from(v2, u2);
    if (t1.equals(t2))
        throw new RuntimeException("should not be equal");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:7,代码来源:Basic.java

示例3: testOneModule

import java.nio.file.attribute.FileTime; //导入方法依赖的package包/类
@Test
public void testOneModule(Path base) throws Exception {
    Path src = base.resolve("src");
    Path m1 = src.resolve("m1x");
    Path build = base.resolve("build");
    Files.createDirectories(build);

    tb.writeJavaFiles(m1,
            "module m1x {}",
            "package test; public class Test {}");

    new JavacTask(tb)
            .options("-m", "m1x", "--module-source-path", src.toString(), "-d", build.toString())
            .run(Task.Expect.SUCCESS)
            .writeAll();

    Path moduleInfoClass = build.resolve("m1x/module-info.class");
    Path testTestClass = build.resolve("m1x/test/Test.class");

    FileTime moduleInfoTimeStamp = Files.getLastModifiedTime(moduleInfoClass);
    FileTime testTestTimeStamp = Files.getLastModifiedTime(testTestClass);

    Path moduleInfo = m1.resolve("module-info.java");
    if (moduleInfoTimeStamp.compareTo(Files.getLastModifiedTime(moduleInfo)) < 0) {
        throw new AssertionError("Classfiles too old!");
    }

    Path testTest = m1.resolve("test/Test.java");
    if (testTestTimeStamp.compareTo(Files.getLastModifiedTime(testTest)) < 0) {
        throw new AssertionError("Classfiles too old!");
    }

    Thread.sleep(2000); //timestamps

    new JavacTask(tb)
            .options("-m", "m1x", "--module-source-path", src.toString(), "-d", build.toString())
            .run(Task.Expect.SUCCESS)
            .writeAll();

    if (!moduleInfoTimeStamp.equals(Files.getLastModifiedTime(moduleInfoClass))) {
        throw new AssertionError("Classfile update!");
    }

    if (!testTestTimeStamp.equals(Files.getLastModifiedTime(testTestClass))) {
        throw new AssertionError("Classfile update!");
    }

    Thread.sleep(2000); //timestamps

    Files.setLastModifiedTime(testTest, FileTime.fromMillis(System.currentTimeMillis()));

    new JavacTask(tb)
            .options("-m", "m1x", "--module-source-path", src.toString(), "-d", build.toString())
            .run(Task.Expect.SUCCESS)
            .writeAll();

    if (!moduleInfoTimeStamp.equals(Files.getLastModifiedTime(moduleInfoClass))) {
        throw new AssertionError("Classfile update!");
    }

    if (Files.getLastModifiedTime(testTestClass).compareTo(Files.getLastModifiedTime(testTest)) < 0) {
        throw new AssertionError("Classfiles too old!");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:65,代码来源:MOptionTest.java


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