List of usage examples for org.apache.commons.io FileUtils cleanDirectory
public static void cleanDirectory(File directory) throws IOException
From source file:com.yahoo.rdl.maven.RdlTest.java
@Before public void setUp() throws Exception { Injector injector = Guice//from w w w.j av a 2 s .c o m .createInjector(Modules.override(Modules.combine(new TestModule(), new AbstractModule() { @Override protected void configure() { bind(Path.class).annotatedWith(ScratchSpace.class) .toInstance(Paths.get("target", "rdl", name.getMethodName())); } })).with(getOverrides())); injector.injectMembers(this); Files.createDirectories(scratchSpace); FileUtils.cleanDirectory(scratchSpace.toFile()); }
From source file:github.srlee309.lessWrongBookCreator.utilities.DirectoryPurger.java
/** * Removes all files and subFiles in the given directory * @param dir to purge//from ww w. j av a2 s.c om * @throws IOException if dir cannot be cleaned */ public void purgeDirectory(File dir) throws IOException { if (dir != null && dir.isDirectory()) { FileUtils.cleanDirectory(dir); } }
From source file:com.github.ipaas.ideploy.agent.handler.BackupCodeHandlerTest.java
/** * @throws java.lang.Exception/*from ww w .java2s. co m*/ */ @Before public void setUp() throws Exception { File srcFile = new File(SRC_PATH); if (srcFile.exists()) { FileUtils.cleanDirectory(srcFile); } else { srcFile.mkdirs(); } File targetFile = new File(TARGET_PATH); if (targetFile.exists()) { FileUtils.cleanDirectory(targetFile); } else { targetFile.mkdirs(); } for (int i = 0; i < 10; i++) { FileUtils.writeStringToFile(new File(SRC_PATH + "/" + i), String.valueOf(i)); } for (int i = 10; i < 20; i++) { new File(SRC_PATH + "/" + i).mkdir(); } }
From source file:de.tobiasbruns.content.storage.MetaDataServiceITCase.java
@After public void cleanup() throws IOException { FileUtils.cleanDirectory(new File("testroot")); }
From source file:com.thoughtworks.go.buildsession.CleandirCommandExecutor.java
@Override public boolean execute(BuildCommand command, BuildSession buildSession) { File dir = buildSession.resolveRelativeDir(command.getWorkingDirectory(), command.getStringArg("path")); String[] allowed = command.getArrayArg("allowed"); if (allowed.length == 0) { try {/*from ww w.j ava 2 s . c om*/ FileUtils.cleanDirectory(dir); } catch (IOException e) { return false; } } else { DirectoryCleaner cleaner = new DirectoryCleaner(dir, buildSession.processOutputStreamConsumer()); cleaner.allowed(allowed); cleaner.clean(); } return true; }
From source file:com.ericsson.eiffel.remrem.semantics.schemas.LocalRepo.java
/** * This method is used to read Eiffel Schemas that are cloned from Eiffel * Repo/*from w w w.jav a 2 s . c o m*/ */ public void readSchemas() { try { FileUtils.cleanDirectory( new File(EiffelConstants.USER_DIR + File.separator + EiffelConstants.INPUT_EIFFEL_SCHEMAS)); } catch (IOException e) { e.printStackTrace(); } jsonEventNames = new ArrayList<String>(); jsonEventSchemas = new ArrayList<File>(); String filePath = localSchemasPath + EiffelConstants.SCHEMA_LOCATION; loadEiffelSchemas(filePath, ""); }
From source file:com.talis.entity.db.babudb.BabuDbEntityDatabaseConcurrencyTest.java
@Before public void setup() throws Exception { tmpDirs = new File[NUM_DBS]; for (int i = 0; i < NUM_DBS; i++) { File tmpDir = new File(FileUtils.getTempDirectory(), "db-con-test-" + i); FileUtils.forceMkdir(tmpDir);/* ww w . j a v a 2s. co m*/ FileUtils.cleanDirectory(tmpDir); tmpDirs[i] = tmpDir; } super.setup(); }
From source file:com.datis.irc.kryo.KryoSerializerTest.java
@Override protected void setUp() throws Exception { try {//from w w w.j av a2s. com System.out.println("DELETE and Create Folder"); File f = new File(addressFolder); File fKryo = new File(addressFolder + "/kryo"); File fpojo = new File(addressFolder + "/pojo"); FileUtils.cleanDirectory(f); //clean out directory (this is optional -- but good know) FileUtils.forceDelete(f); //delete directory FileUtils.forceMkdir(f); //create directory FileUtils.forceMkdir(fKryo); //create directory FileUtils.forceMkdir(fpojo); //create directory } catch (IOException e) { System.out.println("ERROR in Create And Delete DirectoryS"); e.printStackTrace(); } }
From source file:de.berlios.jsunit.ant.JsUnitTaskTest.java
protected void setUp() throws Exception { super.setUp(); outDir = new File("target/junit"); if (outDir.exists()) { FileUtils.cleanDirectory(outDir); }/*from w w w. j a v a 2 s . c o m*/ project = new Project(); project.setBaseDir(new File(".")); }
From source file:gr.aueb.mipmapgui.controller.file.ActionCleanDirectory.java
public void performAction(String user) { try {//from ww w. jav a 2s. c om String sourceTempDirectory = Costanti.SERVER_MAIN_FOLDER + Costanti.SERVER_FILES_FOLDER + user + "/" + Costanti.SERVER_TEMP_FOLDER + "/" + Costanti.SERVER_SOURCE_FOLDER; File directory = new File(sourceTempDirectory); FileUtils.cleanDirectory(directory); String targetTempDirectory = Costanti.SERVER_MAIN_FOLDER + Costanti.SERVER_FILES_FOLDER + user + "/" + Costanti.SERVER_TEMP_FOLDER + "/" + Costanti.SERVER_TARGET_FOLDER; File directory2 = new File(targetTempDirectory); FileUtils.cleanDirectory(directory2); } catch (IOException ex) { Logger.getLogger(ActionDeleteMappingTask.class.getName()).log(Level.SEVERE, null, ex); } }