本文整理汇总了Java中com.google.common.io.MoreFiles.deleteRecursively方法的典型用法代码示例。如果您正苦于以下问题:Java MoreFiles.deleteRecursively方法的具体用法?Java MoreFiles.deleteRecursively怎么用?Java MoreFiles.deleteRecursively使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.io.MoreFiles
的用法示例。
在下文中一共展示了MoreFiles.deleteRecursively方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installApplication
import com.google.common.io.MoreFiles; //导入方法依赖的package包/类
@Override
public void installApplication(Path ipaOrAppPath) throws IosDeviceException {
try {
if (Files.isDirectory(ipaOrAppPath)) {
await(simctl.install(ipaOrAppPath.toString()));
} else {
Path tmpDir = Files.createTempDirectory("app");
try {
unzipFile(ipaOrAppPath, tmpDir);
Path appPath =
tmpDir
.resolve("Payload")
.resolve(MoreFiles.getNameWithoutExtension(ipaOrAppPath) + ".app");
await(simctl.install(appPath.toString()));
} finally {
MoreFiles.deleteRecursively(tmpDir, RecursiveDeleteOption.ALLOW_INSECURE);
}
}
} catch (IOException e) {
throw new IosDeviceException(this, e);
}
}
示例2: cleanUp
import com.google.common.io.MoreFiles; //导入方法依赖的package包/类
@After
public void cleanUp() throws Exception {
appContext.stopLogging();
DataStore.closeConnection(dbconn);
try {
MoreFiles
.deleteRecursively(Paths.get(DataStore.getDbDir(testDbName)), RecursiveDeleteOption.ALLOW_INSECURE);
} catch (IOException e) {
// DONT make test failure.
System.err.println("test db clean-up failure, remove manually later :P");
e.printStackTrace();
}
}
示例3: close
import com.google.common.io.MoreFiles; //导入方法依赖的package包/类
@Override
public void close() {
try {
MoreFiles.deleteRecursively(fProjectPath);
} catch (IOException e) {
}
}
示例4: stopService
import com.google.common.io.MoreFiles; //导入方法依赖的package包/类
private void stopService() {
try {
brokerService.stop();
MoreFiles.deleteRecursively(tempDir.toPath(), RecursiveDeleteOption.ALLOW_INSECURE);
brokerService = null;
} catch (Exception e) {
throw new IllegalStateException("Could not stop broker", e);
}
}
示例5: clearCrashLogs
import com.google.common.io.MoreFiles; //导入方法依赖的package包/类
@Override
public void clearCrashLogs() throws IosDeviceException {
try {
Path tempDir = Files.createTempDirectory("artifacts");
try {
idevice.crashreport(tempDir.toString());
} finally {
MoreFiles.deleteRecursively(tempDir, RecursiveDeleteOption.ALLOW_INSECURE);
}
} catch (IOException e) {
throw new IosDeviceException(this, e);
}
}
示例6: deleteRecursively
import com.google.common.io.MoreFiles; //导入方法依赖的package包/类
/**
* Delete all the contents of a path recursively.
*
* <p>First we try to delete securely. In case the FileSystem doesn't support it,
* delete it insecurely.
*/
public static void deleteRecursively(Path path) throws IOException {
try {
MoreFiles.deleteRecursively(path);
} catch (InsecureRecursiveDeleteException ignore) {
logger.warning(String.format("Secure delete not supported. Deleting '%s' insecurely.",
path));
MoreFiles.deleteRecursively(path, RecursiveDeleteOption.ALLOW_INSECURE);
}
}
示例7: reindexFromScratch
import com.google.common.io.MoreFiles; //导入方法依赖的package包/类
@Test
public void reindexFromScratch() throws Exception {
setUpChange();
MoreFiles.deleteRecursively(sitePaths.index_dir, RecursiveDeleteOption.ALLOW_INSECURE);
Files.createDirectory(sitePaths.index_dir);
assertServerStartupFails();
runGerrit("reindex", "-d", sitePaths.site_path.toString(), "--show-stack-trace");
assertReady(ChangeSchemaDefinitions.INSTANCE.getLatest().getVersion());
try (ServerContext ctx = startServer()) {
GerritApi gApi = ctx.getInjector().getInstance(GerritApi.class);
// Query change index
assertThat(gApi.changes().query("message:Test").get().stream().map(c -> c.changeId))
.containsExactly(changeId);
// Query account index
assertThat(gApi.accounts().query("admin").get().stream().map(a -> a._accountId))
.containsExactly(adminId.get());
// Query group index
assertThat(
gApi.groups()
.query("Group")
.withOption(MEMBERS)
.get()
.stream()
.flatMap(g -> g.members.stream())
.map(a -> a._accountId))
.containsExactly(adminId.get());
}
}
示例8: createTestFiles
import com.google.common.io.MoreFiles; //导入方法依赖的package包/类
@Test
public void createTestFiles() throws SQLException, ClassNotFoundException, IOException {
File genJavaDir = pathRelativeToProjectRoot("pom.xml", "../lsql-cli-tests/src/generated/java");
if (genJavaDir.exists()) {
MoreFiles.deleteRecursively(genJavaDir.toPath());
}
File genTSDir = pathRelativeToProjectRoot("pom.xml", "../lsql-cli-tests/src/generated/ts");
if (genTSDir.exists()) {
MoreFiles.deleteRecursively(genTSDir.toPath());
}
String url = "jdbc:h2:mem:" + UUID.randomUUID() + ";mode=postgresql";
BasicDataSource ds = new BasicDataSource();
ds.setUrl(url);
ds.setDefaultAutoCommit(false);
Connection connection = ds.getConnection();
LSql lSql = new LSql(TestCliConfig.class, ConnectionProviders.fromInstance(connection));
createTables(lSql);
connection.close();
String[] args = {
"config:" + TestCliConfig.class.getCanonicalName(),
"url:" + url,
"user:",
"password:",
"sqlStatements:" + pathRelativeToProjectRoot("pom.xml", "./src/test/java/com/w11k/lsql/cli/tests"),
"dto:" + pathRelativeToProjectRoot("pom.xml", "./src/test/java/com/w11k/lsql/cli/tests"),
"package:" + TestCliConfig.class.getPackage().getName(),
"di:guice",
"outDirJava:" + genJavaDir.getAbsolutePath(),
"outDirTypeScript:" + genTSDir.getAbsolutePath()
};
Main.main(args);
}