/** * 创建文件或更新时间戳. * * @see {@link com.google.common.io.Files#touch} */ public static void touch(File file) throws IOException { com.google.common.io.Files.touch(file); }
private File touchCacheResourceVersionLockFile(final File resourceVersionDir) throws IOException { final File lockFile = getCacheResourceVersionLockFile(resourceVersionDir); Files.touch(lockFile); return lockFile; }
public void testTouchTime() throws IOException { File temp = createTempFile(); assertTrue(temp.exists()); temp.setLastModified(0); assertEquals(0, temp.lastModified()); Files.touch(temp); assertThat(temp.lastModified()).isNotEqualTo(0); }
public void testTouch() throws IOException { File temp = createTempFile(); assertTrue(temp.exists()); assertTrue(temp.delete()); assertFalse(temp.exists()); Files.touch(temp); assertTrue(temp.exists()); Files.touch(temp); assertTrue(temp.exists()); try { Files.touch( new File(temp.getPath()) { @Override public boolean setLastModified(long t) { return false; } private static final long serialVersionUID = 0; }); fail("expected exception"); } catch (IOException expected) { } }
@Test public void testZipUnzip() throws IOException { Path p1 = temp.newFolder("d1").toPath(); p1.resolve("foo/bar").toFile().mkdirs(); Files.touch(p1.resolve("foo/bar/bar.txt").toFile()); ByteArrayOutputStream bout = new ByteArrayOutputStream(); ZipOutputStream zout = new ZipOutputStream(bout); IOUtils.zipDirectory(p1.toFile(), zout, null); Path p2 = temp.newFolder("d2").toPath(); p2.toFile().mkdirs(); ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); IOUtils.decompress(bin, p2.toFile()); assertTrue(p2.resolve("foo/bar/bar.txt").toFile().exists()); }
Files.touch(jobConfigFile);
/** * 创建文件或更新时间戳. * * @see {@link com.google.common.io.Files#touch} */ public static void touch(File file) throws IOException { com.google.common.io.Files.touch(file); }
/** * 创建文件或更新时间戳. */ public static void touch(File file) throws IOException { Files.touch(file); }
/** * 创建文件或更新时间戳. */ public static void touch(File file) throws IOException { Files.touch(file); }
public ByteArrayFileWriter(final File file) { try { Files.touch(file); fileOutput = new FileOutputStream(file); } catch (IOException e) { throw new IllegalStateException(e); } }
/** * 创建文件或更新时间戳. */ public static void touch(String filePath) throws IOException { Files.touch(getFileByPath(filePath)); }
/** * 创建文件或更新时间戳. */ public static void touch(String filePath) throws IOException { Files.touch(getFileByPath(filePath)); }
private File touchCacheResourceVersionLockFile(final File resourceVersionDir) throws IOException { final File lockFile = getCacheResourceVersionLockFile(resourceVersionDir); Files.touch(lockFile); return lockFile; }
public Optional<Entry<FullyQualifiedName,File>> persist(File srcDirectory, boolean overwrite) throws IOException { File dstFile = fqn.toFile(srcDirectory); if (overwrite || !dstFile.exists()) { Files.createParentDirs(dstFile); Files.touch(dstFile); Files.write(content, dstFile, StandardCharsets.UTF_8); return Optional.of(Maps.immutableEntry(fqn, dstFile)); } else { return Optional.absent(); } }
private static void persistPrefsChecked(IProject project, PersistentModel model) throws IOException { File preferencesFile = preferencesFile(project); if (!preferencesFile.exists()) { Files.createParentDirs(preferencesFile); Files.touch(preferencesFile); } Properties props = PersistentModelConverter.toProperties(model); try (Writer writer = new OutputStreamWriter(new FileOutputStream(preferencesFile), Charsets.UTF_8)) { props.store(writer, ""); } }
private void writeSenchaCfgFile() throws MojoExecutionException { File senchaCfg = new File(getSenchaPackageDirectory().getPath(), SenchaUtils.SENCHA_PACKAGE_CONFIG); getLog().info("Write " + SenchaUtils.SENCHA_PACKAGE_CONFIG); try { Files.createParentDirs(senchaCfg); Files.touch(senchaCfg); } catch (IOException e) { throw new MojoExecutionException("Could not create " + senchaCfg.getAbsolutePath(), e); } }
private void reopenFile() throws IOException { if (file != null) { file.delete(); } file = File.createTempFile("table", ".db"); file.delete(); com.google.common.io.Files.touch(file); }
@Test public void testZipUnzip() throws IOException { Path p1 = temp.newFolder("d1").toPath(); p1.resolve("foo/bar").toFile().mkdirs(); Files.touch(p1.resolve("foo/bar/bar.txt").toFile()); ByteArrayOutputStream bout = new ByteArrayOutputStream(); ZipOutputStream zout = new ZipOutputStream(bout); IOUtils.zipDirectory(p1.toFile(), zout, null); Path p2 = temp.newFolder("d2").toPath(); p2.toFile().mkdirs(); ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); IOUtils.decompress(bin, p2.toFile()); assertTrue(p2.resolve("foo/bar/bar.txt").toFile().exists()); }
public void testTouchTime() throws IOException { File temp = createTempFile(); assertTrue(temp.exists()); temp.setLastModified(0); assertEquals(0, temp.lastModified()); Files.touch(temp); assertThat(temp.lastModified()).isNotEqualTo(0); }