APISonar


com.google.common.io.Files.touch

> com > google > common > io > Files > touch
com APIs google APIs common APIs io APIs Files APIs touch APIs

Example 1
static void touchShardFile(File shardFile) {
    if (shardFile != null) {
      try {
        Files.touch(shardFile);
      } catch (IOException e) {
        throw new RuntimeException("Error writing shard file " + shardFile, e);
      }
    }
  }
Example 2
private File touchCacheResourceVersionLockFile(final File resourceVersionDir) throws IOException {
        final File lockFile = getCacheResourceVersionLockFile(resourceVersionDir);
        Files.touch(lockFile);
        return lockFile;
    }
Example 3
public void whenCreatingAFileWithFileSeparator_thenFileIsCreated() throws IOException {
        File tempDirectory = new File(System.getProperty("java.io.tmpdir"));
        File newFile = new File(tempDirectory.getAbsolutePath() + File.separator + "newFile2.txt");

        assertFalse(newFile.exists());

        Files.touch(newFile);

        assertTrue(newFile.exists());
    }
Example 4
private static void makeTestVmTree(File baseDir) throws IOException {
    File bin = new File(baseDir, "testVm/bin");
    bin.mkdirs();
    File java = new File(bin, "java");
    Files.touch(java);
  }
Example 5
public void testDirectoryCreateFailed() throws IOException {
    File zipDir = new File(tmpDir, "zipdir");
    assertTrue(zipDir.mkdir());
    ZipFiles.zipDirectory(tmpDir, zipFile);
    File targetDirectory = Files.createTempDir();
    // Touch a file where the directory should be.
    Files.touch(new File(targetDirectory, "zipdir"));
    try {
      ZipFiles.unzipFile(zipFile, targetDirectory);
      fail("We expect the IOException, but it never occured");
    } catch (IOException e) {
      // This is the expected exception - we passed the test.
    }
  }
Example 6
public static void init() throws IOException {
        root = File.createTempFile("file", "tmp", new File("target"));
        root.delete();
        root.mkdirs();

        File wcs = new File(root, "wcs"); 
        wcs.mkdir();

        Files.touch(new File(wcs, "BlueMarble.tiff"));

        validator = new FileExistsValidator();
        validator.baseDirectory = root;
    }
Example 7
public void testResolveFilePathRelativeToBuildFileDirectoryInRootDirectory() throws IOException {
    Files.touch(new File(filesystem.getProjectRoot(), "build.xml"));

    BuildTarget buildTarget = BuildTargetFactory.newInstance("//:wakizashi");
    BuildRuleFactoryParams params = new BuildRuleFactoryParams(
        null /* instance */,
        filesystem,
        parser,
        buildTarget,
        new FakeRuleKeyBuilderFactory());

    assertEquals(Paths.get("build.xml"),
        params.resolveFilePathRelativeToBuildFileDirectory("build.xml"));
  }