本文整理汇总了Java中org.springframework.util.FileSystemUtils.deleteRecursively方法的典型用法代码示例。如果您正苦于以下问题:Java FileSystemUtils.deleteRecursively方法的具体用法?Java FileSystemUtils.deleteRecursively怎么用?Java FileSystemUtils.deleteRecursively使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.util.FileSystemUtils
的用法示例。
在下文中一共展示了FileSystemUtils.deleteRecursively方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.springframework.util.FileSystemUtils; //导入方法依赖的package包/类
/**
* Pre-load some fake images
*
* @return Spring Boot {@link CommandLineRunner} automatically run after app context is loaded.
*/
@Bean
CommandLineRunner setUp() throws IOException {
return (args) -> {
FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));
Files.createDirectory(Paths.get(UPLOAD_ROOT));
FileCopyUtils.copy("Test file",
new FileWriter(UPLOAD_ROOT +
"/learning-spring-boot-cover.jpg"));
FileCopyUtils.copy("Test file2",
new FileWriter(UPLOAD_ROOT +
"/learning-spring-boot-2nd-edition-cover.jpg"));
FileCopyUtils.copy("Test file3",
new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
};
}
示例2: setUp
import org.springframework.util.FileSystemUtils; //导入方法依赖的package包/类
/**
* Pre-load some test images
*
* @return Spring Boot {@link CommandLineRunner} automatically
* run after app context is loaded.
*/
@Bean
CommandLineRunner setUp() throws IOException {
return (args) -> {
FileSystemUtils.deleteRecursively(new File(UPLOAD_ROOT));
Files.createDirectory(Paths.get(UPLOAD_ROOT));
FileCopyUtils.copy("Test file",
new FileWriter(UPLOAD_ROOT +
"/learning-spring-boot-cover.jpg"));
FileCopyUtils.copy("Test file2",
new FileWriter(UPLOAD_ROOT +
"/learning-spring-boot-2nd-edition-cover.jpg"));
FileCopyUtils.copy("Test file3",
new FileWriter(UPLOAD_ROOT + "/bazinga.png"));
};
}
示例3: setUp
import org.springframework.util.FileSystemUtils; //导入方法依赖的package包/类
@Before
public void setUp() throws IOException {
operations.dropCollection(Image.class);
operations.insert(new Image("1",
"learning-spring-boot-cover.jpg"));
operations.insert(new Image("2",
"learning-spring-boot-2nd-edition-cover.jpg"));
operations.insert(new Image("3",
"bazinga.png"));
FileSystemUtils.deleteRecursively(new File(ImageService.UPLOAD_ROOT));
Files.createDirectory(Paths.get(ImageService.UPLOAD_ROOT));
FileCopyUtils.copy("Test file",
new FileWriter(ImageService.UPLOAD_ROOT +
"/learning-spring-boot-cover.jpg"));
FileCopyUtils.copy("Test file2",
new FileWriter(ImageService.UPLOAD_ROOT +
"/learning-spring-boot-2nd-edition-cover.jpg"));
FileCopyUtils.copy("Test file3",
new FileWriter(ImageService.UPLOAD_ROOT + "/bazinga.png"));
}
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:27,代码来源:ImageServiceTests.java
示例4: explodedWarHasOnlyWebInfClassesAndContentsOfWebInfLibOnClasspath
import org.springframework.util.FileSystemUtils; //导入方法依赖的package包/类
@Test
public void explodedWarHasOnlyWebInfClassesAndContentsOfWebInfLibOnClasspath()
throws Exception {
File warRoot = new File("target/exploded-war");
FileSystemUtils.deleteRecursively(warRoot);
warRoot.mkdirs();
File webInfClasses = new File(warRoot, "WEB-INF/classes");
webInfClasses.mkdirs();
File webInfLib = new File(warRoot, "WEB-INF/lib");
webInfLib.mkdirs();
File webInfLibFoo = new File(webInfLib, "foo.jar");
new JarOutputStream(new FileOutputStream(webInfLibFoo)).close();
WarLauncher launcher = new WarLauncher(new ExplodedArchive(warRoot, true));
List<Archive> archives = launcher.getClassPathArchives();
assertThat(archives).hasSize(2);
assertThat(getUrls(archives)).containsOnly(webInfClasses.toURI().toURL(),
new URL("jar:" + webInfLibFoo.toURI().toURL() + "!/"));
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:WarLauncherTests.java
示例5: explodedWarHasOnlyWebInfClassesAndContentsOfWebInfLibOnClasspath
import org.springframework.util.FileSystemUtils; //导入方法依赖的package包/类
@Test
public void explodedWarHasOnlyWebInfClassesAndContentsOfWebInfLibOnClasspath()
throws Exception {
File warRoot = new File("target/exploded-war");
FileSystemUtils.deleteRecursively(warRoot);
warRoot.mkdirs();
File webInfClasses = new File(warRoot, "WEB-INF/classes");
webInfClasses.mkdirs();
File webInfLib = new File(warRoot, "WEB-INF/lib");
webInfLib.mkdirs();
File webInfLibFoo = new File(webInfLib, "foo.jar");
new JarOutputStream(new FileOutputStream(webInfLibFoo)).close();
WarLauncher launcher = new WarLauncher(new ExplodedArchive(warRoot, true));
List<Archive> archives = launcher.getClassPathArchives();
assertEquals(2, archives.size());
assertThat(getUrls(archives), hasItems(webInfClasses.toURI().toURL(),
new URL("jar:" + webInfLibFoo.toURI().toURL() + "!/")));
}
示例6: run
import org.springframework.util.FileSystemUtils; //导入方法依赖的package包/类
@Override
public void run(String... args) throws Exception {
FileSystemUtils.deleteRecursively(new File(dbDataDir));
LOG.info("Creating Spatial alias");
jdbcTemplate.execute("CREATE ALIAS IF NOT EXISTS SPATIAL_INIT FOR \"org.h2gis.h2spatialext.CreateSpatialExtension.initSpatialExtension\";");
LOG.info("Initializing spatial extension");
jdbcTemplate.execute("CALL SPATIAL_INIT();");
loadData("DOP_ZPS_Stani_l_mercator.shp", "DOP_ZPS_Stani_l");
loadData("DOP_ZachParkoviste_b_mercator.shp", "DOP_ZachParkoviste_b");
loadData("DOP_ZachParkoviste_b_mercator-buffer20.shp", "DOP_ZachParkoviste_b_buffer20");
loadData("DOP_ZPS_Automaty_b_mercator.shp", "DOP_ZPS_Automaty_b");
loadData("DOP_ZPS_Automaty_b_mercator-buffer20.shp", "DOP_ZPS_Automaty_b_buffer20");
}
示例7: deserializePackageFromDatabase
import org.springframework.util.FileSystemUtils; //导入方法依赖的package包/类
private Package deserializePackageFromDatabase(PackageMetadata packageMetadata) {
// package file was uploaded to a local DB hosted repository
Path tmpDirPath = null;
try {
tmpDirPath = TempFileUtils.createTempDirectory("skipper");
File targetPath = new File(tmpDirPath + File.separator + packageMetadata.getName());
targetPath.mkdirs();
File targetFile = PackageFileUtils.calculatePackageZipFile(packageMetadata, targetPath);
try {
StreamUtils.copy(packageMetadata.getPackageFile().getPackageBytes(), new FileOutputStream(targetFile));
}
catch (IOException e) {
throw new SkipperException(
"Could not copy package file for " + packageMetadata.getName() + "-"
+ packageMetadata.getVersion() +
" from database to target file " + targetFile,
e);
}
ZipUtil.unpack(targetFile, targetPath);
Package pkgToReturn = this.packageReader.read(new File(targetPath, packageMetadata.getName() + "-" +
packageMetadata.getVersion()));
pkgToReturn.setMetadata(packageMetadata);
return pkgToReturn;
}
finally {
if (tmpDirPath != null && !FileSystemUtils.deleteRecursively(tmpDirPath.toFile())) {
logger.warn("Temporary directory can not be deleted: " + tmpDirPath);
}
}
}
示例8: delete
import org.springframework.util.FileSystemUtils; //导入方法依赖的package包/类
@Override
public Node delete(String path) {
String rootPath = PathUtil.rootPath(path);
Node flow = find(rootPath).root();
// delete related userAuth
userFlowService.unAssign(flow);
// delete job
jobService.delete(rootPath);
// delete job number
jobNumberDao.delete(new JobNumber(path));
// delete flow
flowDao.delete(flow);
// delete related yml storage
ymlService.delete(flow);
// delete local flow folder
Path flowWorkspace = NodeUtil.workspacePath(workspace, flow);
FileSystemUtils.deleteRecursively(flowWorkspace.toFile());
getTreeCache().evict(rootPath);
// stop yml loading tasks
ymlService.stopLoad(flow);
return flow;
}
示例9: getConnectorClasspath
import org.springframework.util.FileSystemUtils; //导入方法依赖的package包/类
private String getConnectorClasspath(Connector connector) throws IOException, InterruptedException {
byte[] pom = new byte[0]; // TODO: Fix generation to use an Action projectGenerator.generatePom(connector);
java.nio.file.Path tmpDir = Files.createTempDirectory("syndesis-connector");
try {
Files.write(tmpDir.resolve("pom.xml"), pom);
ArrayList<String> args = new ArrayList<>();
args.add("mvn");
args.add("org.apache.maven.plugins:maven-dependency-plugin:3.0.0:build-classpath");
if (localMavenRepoLocation != null) {
args.add("-Dmaven.repo.local=" + localMavenRepoLocation);
}
ProcessBuilder builder = new ProcessBuilder().command(args)
.redirectError(ProcessBuilder.Redirect.INHERIT)
.directory(tmpDir.toFile());
Map<String, String> environment = builder.environment();
environment.put("MAVEN_OPTS", "-Xmx64M");
Process mvn = builder.start();
try {
String result = parseClasspath(mvn.getInputStream());
if (mvn.waitFor() != 0) {
throw new IOException("Could not get the connector classpath, mvn exit value: " + mvn.exitValue());
}
return result;
} finally {
mvn.getInputStream().close();
mvn.getOutputStream().close();
}
} finally {
FileSystemUtils.deleteRecursively(tmpDir.toFile());
}
}
示例10: init
import org.springframework.util.FileSystemUtils; //导入方法依赖的package包/类
@Before
public void init() {
this.outputDirectory = new File("target/test/remove");
this.originDirectory = new File("target/test/keep");
FileSystemUtils.deleteRecursively(this.outputDirectory);
FileSystemUtils.deleteRecursively(this.originDirectory);
this.outputDirectory.mkdirs();
this.originDirectory.mkdirs();
}
示例11: deleteDrop
import org.springframework.util.FileSystemUtils; //导入方法依赖的package包/类
@Override
public void deleteDrop() throws DropExporterException {
checkIsInitialized();
Path deletePath = Paths.get(fileSystemDropExporterConfig.getDropFolderPath());
boolean deleteRecursively = FileSystemUtils.deleteRecursively(deletePath.toFile());
if (!deleteRecursively) {
String msg = "Cannot delete the drop folder";
logger.error(msg);
throw new DropExporterException(msg);
}
}
示例12: setUp
import org.springframework.util.FileSystemUtils; //导入方法依赖的package包/类
@BeforeMethod
@Override
public void setUp() throws Exception
{
File file = new File("test/data");
if(!FileSystemUtils.deleteRecursively(file)) {
System.out.println("Problem occurs when deleting the directory : test/data" );
}
super.setUp();
}
示例13: main
import org.springframework.util.FileSystemUtils; //导入方法依赖的package包/类
public static void main(String[] args) {
// Clean out any ActiveMQ data from a previous run
FileSystemUtils.deleteRecursively(new File("activemq-data"));
// Launch the application
ConfigurableApplicationContext context = SpringApplication.run(TradesGenerator.class, args);
JmsTemplate jmsTemplate = context.getBean(JmsTemplate.class);
// Marking this as Topic - This value is false by default which means it is a Queue
jmsTemplate.setPubSubDomain(true);
for (int mCount = 1; mCount <= 1000; mCount++) {
// Send a message
MessageCreator messageCreator = new MessageCreator() {
@Override
public Message createMessage(Session session) throws JMSException {
StringBuilder tradeBuilder = new StringBuilder();
tradeBuilder.append(tradeCount);
tradeBuilder.append(SEPARATOR);
tradeBuilder.append("LE-");
tradeBuilder.append((int) (Math.random() * 10));
tradeBuilder.append(SEPARATOR);
tradeBuilder.append("value");
tradeBuilder.append((int) (Math.random() * 100));
tradeBuilder.append(SEPARATOR);
tradeBuilder.append(new Date());
tradeBuilder.append(SEPARATOR);
tradeBuilder.append(new Date().getTime());
tradeCount++;
return session.createTextMessage(tradeBuilder.toString());
}
};
logger.info("Sending message with ID =" + mCount);
jmsTemplate.send(TOPIC_NAME, messageCreator);
}
}
示例14: mongoWritesToCustomDatabaseDir
import org.springframework.util.FileSystemUtils; //导入方法依赖的package包/类
@Test
public void mongoWritesToCustomDatabaseDir() {
File customDatabaseDir = new File("target/custom-database-dir");
FileSystemUtils.deleteRecursively(customDatabaseDir);
this.context = new AnnotationConfigApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, "spring.data.mongodb.port=0",
"spring.mongodb.embedded.storage.databaseDir="
+ customDatabaseDir.getPath());
this.context.register(EmbeddedMongoAutoConfiguration.class,
MongoClientConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertThat(customDatabaseDir).isDirectory();
assertThat(customDatabaseDir.listFiles()).isNotEmpty();
}
示例15: deleteLocalRepository
import org.springframework.util.FileSystemUtils; //导入方法依赖的package包/类
@Before
@After
public void deleteLocalRepository() {
FileSystemUtils.deleteRecursively(new File("target/repository"));
System.clearProperty("grape.root");
System.clearProperty("groovy.grape.report.downloads");
}