jodd.io.FileUtil.touch()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(549)

本文整理了Java中jodd.io.FileUtil.touch()方法的一些代码示例,展示了FileUtil.touch()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.touch()方法的具体详情如下:
包路径:jodd.io.FileUtil
类名称:FileUtil
方法名:touch

FileUtil.touch介绍

[英]Implements the Unix "touch" utility. It creates a new file with size 0 or, if the file exists already, it is opened and closed without modifying it, but updating the file date and time.
[中]实现Unix“touch”实用程序。它将创建一个大小为0的新文件,或者,如果该文件已经存在,则打开和关闭该文件时不进行修改,而是更新文件日期和时间。

代码示例

代码示例来源:origin: redisson/redisson

protected ZipBuilder(File zipFile) throws IOException {
  if (!FileUtil.isExistingFile(zipFile)) {
    FileUtil.touch(zipFile);
  }
  zos = new ZipOutputStream(new FileOutputStream(zipFile));
  targetZipFile = zipFile;
  targetBaos = null;
}

代码示例来源:origin: redisson/redisson

/**
 * @see #touch(java.io.File)
 */
public static void touch(String file) throws IOException {
  touch(file(file));
}
/**

代码示例来源:origin: redisson/redisson

/**
 * Enables usage of provided watch file.
 */
public DirWatcher useWatchFile(String name) {
  watchFile = new File(dir, name);
  if (!watchFile.isFile() || !watchFile.exists()) {
    try {
      FileUtil.touch(watchFile);
    } catch (IOException ioex) {
      throw new DirWatcherException("Invalid watch file: " + name, ioex);
    }
  }
  watchFileLastAccessTime = watchFile.lastModified();
  return this;
}

代码示例来源:origin: oblac/jodd

protected ZipBuilder(final File zipFile) throws IOException {
  if (!FileUtil.isExistingFile(zipFile)) {
    FileUtil.touch(zipFile);
  }
  zos = new ZipOutputStream(new FileOutputStream(zipFile));
  targetZipFile = zipFile;
  targetBaos = null;
}

代码示例来源:origin: oblac/jodd

/**
 * @see #touch(File)
 */
public static void touch(final String file) throws IOException {
  touch(file(file));
}

代码示例来源:origin: oblac/jodd

/**
 * Enables usage of provided watch file.
 */
public DirWatcher useWatchFile(final String name) {
  watchFile = new File(dir, name);
  if (!watchFile.isFile() || !watchFile.exists()) {
    try {
      FileUtil.touch(watchFile);
    } catch (IOException ioex) {
      throw new DirWatcherException("Invalid watch file: " + name, ioex);
    }
  }
  watchFileLastAccessTime = watchFile.lastModified();
  return this;
}

代码示例来源:origin: oblac/jodd

@BeforeAll
public void beforeAll() throws Exception {
  // setup for successful deletion of paths
  {
    baseDir_Successful.mkdirs();
    Files.createDirectories(new File(baseDir_Successful, "ggg/hhh/").toPath());
    FileUtil.touch(new File(baseDir_Successful, "ggg/hhh/hello.txt"));
    FileUtil.touch(new File(baseDir_Successful, "jodd.makes.fun"));
  }
  // setup for non successful deletion of paths
  {
    baseDir_Not_Successful.mkdirs();
    Files.createDirectories(new File(baseDir_Not_Successful, "abc/def").toPath());
    FileUtil.touch(locked_file);
  }
}

代码示例来源:origin: oblac/jodd

@Test
void testDirWatcherWithFile() throws IOException {
  DirWatcher dirWatcher = new DirWatcher(dataRoot)
      .monitor("*.md")
      .useWatchFile("watch.txt");
  final StringBuilder sb = new StringBuilder();
  dirWatcher.register(
    event -> sb.append(event.type().name() + ":" + event.target().getName() + "\n"));
  dirWatcher.start(100);
  File watchFile = new File(dataRoot, "watch.txt");
  File destFile = new File(dataRoot, "jodd.md");
  FileUtil.writeString(destFile, "#Jodd");
  FileUtil.touch(watchFile);
  ThreadUtil.sleep(600);
  FileUtil.writeString(destFile, "#Jodd2");
  ThreadUtil.sleep(600);
  FileUtil.delete(destFile);
  FileUtil.touch(watchFile);
  ThreadUtil.sleep(600);
  dirWatcher.stop();
  assertEquals(
      DirWatcherEvent.Type.CREATED + ":jodd.md\n" +
      //DirWatcher.Event.MODIFIED + ":jodd.md\n" +
      DirWatcherEvent.Type.DELETED + ":jodd.md\n",
      sb.toString());
}

代码示例来源:origin: org.jodd/jodd-core

protected ZipBuilder(final File zipFile) throws IOException {
  if (!FileUtil.isExistingFile(zipFile)) {
    FileUtil.touch(zipFile);
  }
  zos = new ZipOutputStream(new FileOutputStream(zipFile));
  targetZipFile = zipFile;
  targetBaos = null;
}

代码示例来源:origin: org.jodd/jodd-core

/**
 * @see #touch(File)
 */
public static void touch(final String file) throws IOException {
  touch(file(file));
}

代码示例来源:origin: org.jodd/jodd-core

/**
 * Enables usage of provided watch file.
 */
public DirWatcher useWatchFile(final String name) {
  watchFile = new File(dir, name);
  if (!watchFile.isFile() || !watchFile.exists()) {
    try {
      FileUtil.touch(watchFile);
    } catch (IOException ioex) {
      throw new DirWatcherException("Invalid watch file: " + name, ioex);
    }
  }
  watchFileLastAccessTime = watchFile.lastModified();
  return this;
}

相关文章