List of usage examples for org.apache.commons.io FileUtils cleanDirectory
public static void cleanDirectory(File directory) throws IOException
From source file:com.igormaznitsa.jcp.AbstractSpyPreprocessorContextTest.java
@Before public void beforeTest() throws Exception { FileUtils.cleanDirectory(destinationFolder.getRoot()); }
From source file:com.dianping.maven.plugin.tools.wms.WorkspaceManagementServiceImpl.java
@Override public void create(WorkspaceContext context, OutputStream out) throws WorkspaceManagementException { if (context.getProjects() != null && context.getBaseDir() != null && out != null) { printContent("Generating phoenix workspace...", out); if (context.getBaseDir().exists()) { try { FileUtils.cleanDirectory(context.getBaseDir()); } catch (IOException e) { throw new WorkspaceManagementException(e); }//from w w w . j a v a 2 s .c o m } printContent(String.format("Workspace folder(%s) cleared...", context.getBaseDir()), out); try { FileUtils.forceMkdir(context.getBaseDir()); } catch (IOException e) { throw new WorkspaceManagementException(e); } printContent(String.format("Workspace folder(%s) created...", context.getBaseDir()), out); for (String project : context.getProjects()) { Repository repository = repositoryManager.find(project); if (repository == null) { printContent(String.format("Project(%s) not found...", project), out); } CodeRetrieveConfig codeRetrieveConfig = toCodeRetrieveConfig(repository, new File(context.getBaseDir(), project).getAbsolutePath(), out); if (codeRetrieveConfig != null) { printContent( String.format("Checking out project %s(repo:%s)...", project, repository.getRepoUrl()), out); CodeRetrieveService.getInstance().retrieveCode(codeRetrieveConfig); } else { printContent(String.format("Project repository(%s) unknown...", project), out); } } printContent("Generating phoenix-container...", out); generateContainerProject(context); printContent("Phoenix workspace generated...", out); } else { throw new WorkspaceManagementException("projects/basedir can not be null"); } }
From source file:net.erdfelt.android.sdkfido.project.Dir.java
public void ensureEmpty() throws FetchException { try {/* w w w.ja va2s . co m*/ if (basedir.exists()) { FileUtils.cleanDirectory(basedir); } else { FileUtils.forceMkdir(basedir); } } catch (IOException e) { throw new FetchException("Unable to ensure directory is empty: " + basedir, e); } }
From source file:eu.planets_project.services.utils.ZipUtilsTest.java
/** * Test method for {@link eu.planets_project.services.utils.ZipUtils#createZip(java.io.File, java.io.File, java.lang.String, boolean)}. * @throws IOException //from www . j av a 2 s .c om */ @Test public void testCreateZipAndUnzipTo() throws IOException { FileUtils.cleanDirectory(outputFolder); int inputFileCount = ZipUtils.listAllFilesAndFolders(TEST_FILE_FOLDER, new ArrayList<File>()).size(); File zip = ZipUtils.createZip(TEST_FILE_FOLDER, outputFolder, "zipUtilsTest.zip", true); System.out.println("Zip created. Please find it here: " + zip.getAbsolutePath()); String folderName = zip.getName().substring(0, zip.getName().lastIndexOf(".")); File extract = new File(outputFolder, folderName); FileUtils.forceMkdir(extract); List<File> extracted = ZipUtils.unzipTo(zip, extract); System.out.println("Extracted files:" + System.getProperty("line.separator")); for (File file : extracted) { System.out.println(file.getAbsolutePath()); } System.out.println("input file-count: " + inputFileCount); System.out.println("output file-count: " + extracted.size()); }
From source file:com.github.ipaas.ideploy.agent.handler.RollbackCodeHandler.java
@Override public void execute(String flowId, String cmd, Map<String, Object> params, BundleContext bundleContext) throws Exception { String doingCodeVerPath = (String) params.get("doingCodeVerPath"); String usingCodeVerPath = (String) params.get("usingCodeVerPath"); String deployPath = (String) params.get("deployPath"); logger.debug(" params:" + JsonUtil.toJson(params)); if (StringUtil.isNullOrBlank(usingCodeVerPath)) {// ,???,? File localBkFile = new File(String.valueOf(params.get("localBkPath"))); File appRootFile = new File(deployPath); if (appRootFile.exists()) { FileUtils.cleanDirectory(appRootFile);// ? }// w w w . j a va2s. c o m if (!localBkFile.exists()) { logger.error("?:" + localBkFile.getAbsolutePath()); throw new Exception("?,?!"); } FileUtils.copyDirectory(localBkFile, appRootFile); logger.debug("??"); return; } String savePath = String.valueOf(params.get("savePath")); long headRev = SVNRevision.HEAD.getNumber(); Integer hostStatus = Integer.valueOf("" + params.get("hostStatus")); if (hostStatus == 1) {// ,??SVN? SVNUtil.getDeta4UpdateAll(usingCodeVerPath, headRev, savePath); } else { // ?? ? SVNUtil.getDelta(doingCodeVerPath, headRev, usingCodeVerPath, headRev, savePath); } // ? UpdateCodeUtil.updateCode(savePath, deployPath); }
From source file:idp.file_operator.java
public void delete_files() { File del = new File(System.getProperty("user.dir") + "\\src\\main\\temp\\images\\"); try {/*from ww w .j av a2s. c o m*/ FileUtils.cleanDirectory(del); del = new File(System.getProperty("user.dir") + "\\src\\main\\temp\\csv\\"); FileUtils.cleanDirectory(del); } catch (IOException ex) { Logger.getLogger(file_operator.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.example.recognizer.DataFiles.java
public boolean deleteRawLogDir() { try {/*from www .ja v a 2s .c o m*/ FileUtils.cleanDirectory(mDirRawLog); } catch (IOException e) { return false; } return true; }
From source file:com.buddycloud.mediaserver.update.UpdateMediaTest.java
@Override protected void testSetUp() throws Exception { File destDir = new File(configuration.getProperty(MediaServerConfiguration.MEDIA_STORAGE_ROOT_PROPERTY) + File.separator + BASE_CHANNEL); if (!destDir.mkdir()) { FileUtils.cleanDirectory(destDir); }//w w w . j a va 2s . co m FileUtils.copyFile(new File(TEST_FILE_PATH + TEST_IMAGE_NAME), new File(destDir + File.separator + MEDIA_ID)); Media media = buildMedia(MEDIA_ID, TEST_FILE_PATH + TEST_IMAGE_NAME); dataSource.storeMedia(media); // mocks AuthVerifier authClient = xmppTest.getAuthVerifier(); EasyMock.expect(authClient.verifyRequest(EasyMock.matches(BASE_USER), EasyMock.matches(BASE_TOKEN), EasyMock.startsWith(URL))).andReturn(true); PubSubClient pubSubClient = xmppTest.getPubSubClient(); EasyMock.expect(pubSubClient.matchUserCapability(EasyMock.matches(BASE_USER), EasyMock.matches(BASE_CHANNEL), (CapabilitiesDecorator) EasyMock.notNull())).andReturn(true); EasyMock.replay(authClient); EasyMock.replay(pubSubClient); }
From source file:io.jawg.osmcontributor.utils.core.database.DatabaseUpgradeTest.java
@Before public void setup() throws IOException { File baseDir = new File("build/tmp/sqlupdate"); baseDir.mkdirs();//from ww w . j ava2s. c o m FileUtils.cleanDirectory(baseDir); File baseOldBd = new File("src/test/resources/db-v1.sqlite"); newDbFile = new File(baseDir, "new.sqlite"); updatedDbFile = new File(baseDir, "updated.sqlite"); FileUtils.copyFile(baseOldBd, updatedDbFile); Timber.plant(new SysoTree()); }
From source file:eu.openanalytics.rsb.DirectoryDepositITCase.java
@Before public void prepareTests() throws IOException { final File depositRootDirectory = findDepositDirectoryConfiguration(getApplicationName()) .getRootDirectory();//from w w w . java 2 s . c om jobsDirectory = new File(depositRootDirectory, Configuration.DEPOSIT_JOBS_SUBDIR); acceptedDirectory = new File(depositRootDirectory, Configuration.DEPOSIT_ACCEPTED_SUBDIR); resultsDirectory = new File(depositRootDirectory, Configuration.DEPOSIT_RESULTS_SUBDIR); FileUtils.cleanDirectory(jobsDirectory); FileUtils.cleanDirectory(acceptedDirectory); FileUtils.cleanDirectory(resultsDirectory); }