List of usage examples for org.apache.commons.io FileUtils copyDirectory
public static void copyDirectory(File srcDir, File destDir) throws IOException
From source file:ml.shifu.shifu.core.pmml.PMMLTranslatorTest.java
@Test public void testMixTypeVariablePmmlCase() throws Exception { // Step 1. Eval the scores using SHIFU File originModel = new File("src/test/resources/example/labor-neg/DataStore/DataSet1/ModelConfig.json"); File tmpModel = new File("ModelConfig.json"); File originColumn = new File("src/test/resources/example/labor-neg/DataStore/DataSet1/ColumnConfig.json"); File tmpColumn = new File("ColumnConfig.json"); File modelsDir = new File("src/test/resources/example/labor-neg/DataStore/DataSet1/models"); File tmpModelsDir = new File("models"); FileUtils.copyFile(originModel, tmpModel); FileUtils.copyFile(originColumn, tmpColumn); FileUtils.copyDirectory(modelsDir, tmpModelsDir); // run evaluation set ShifuCLI.runEvalScore("EvalA"); File evalScore = new File("evals/EvalA/EvalScore"); ShifuCLI.exportModel(null);// w w w . j a va2 s .c o m // Step 2. Eval the scores using PMML String pmmlPath = "pmmls/ModelK0.pmml"; String DataPath = "src/test/resources/example/labor-neg/DataStore/DataSet1/data.dat"; String OutPath = "model_k_out.dat"; evalPmml(pmmlPath, DataPath, OutPath, ",", "model0"); // Step 3. Compare the SHIFU Eval score and PMML score compareScore(evalScore, new File(OutPath), "model0", "\\|", 1.0); FileUtils.deleteQuietly(new File(OutPath)); FileUtils.deleteQuietly(tmpModel); FileUtils.deleteQuietly(tmpColumn); FileUtils.deleteDirectory(tmpModelsDir); FileUtils.deleteQuietly(new File("./pmmls")); FileUtils.deleteQuietly(new File("evals")); }
From source file:ipat_fx.FXMLDocumentController.java
@FXML private void loadOption(ActionEvent event) { DirectoryChooser dc = new DirectoryChooser(); File file = new File(contextPath + "Saves/"); dc.setInitialDirectory(file);/*from www.j a va 2 s .c o m*/ File dest = new File(dataPath); File seeds = new File(dataPath + "/seeds/"); seeds.delete(); seeds.mkdirs(); dest.delete(); dest.mkdirs(); File src = dc.showDialog(null); try { FileUtils.copyDirectory(src, dest); File profiles = new File(outputFolder.getAbsolutePath() + "/generations"); File[] listFiles = profiles.listFiles(); int lastGeneration = 0; for (File listFile : listFiles) { if (!listFile.isDirectory()) { String profileName = listFile.getName(); System.out.println("profileName : " + profileName); int generation = Integer.parseInt( profileName.substring((profileName.indexOf('_') + 1), profileName.indexOf('-'))); System.out.println("generation : " + generation); if (generation > lastGeneration) { lastGeneration = generation; } } } for (File listFile : listFiles) { String profileName = listFile.getName(); if (Integer.parseInt(profileName.substring((profileName.indexOf('_') + 1), profileName.indexOf('-'))) == lastGeneration) { FileUtils.copyFile(listFile, new File(seeds + "/" + listFile.getName())); } } controller = new Controller(inputFolder, outputFolder, seeds, hintsXML, problemDataFolderName); HashMap<String, Object> display = controller.initialisation(); WebView previewView = (WebView) display.get("previewView"); previewPane.getChildren().add(previewView); @SuppressWarnings("unchecked") HashMap<String, ArrayList<GridPane>> map = (HashMap<String, ArrayList<GridPane>>) display .get("results"); if (tabFlag.equalsIgnoreCase("byImage")) { byImageTab = getByImage(map); byImagePane.setCenter(byImageTab); } else if (tabFlag.equalsIgnoreCase("byProfile")) { byProfileTab = getByProfile(map, controller.noOfProfiles); byProfilePane.setCenter(byProfileTab); } tabPane.getSelectionModel().selectedIndexProperty() .addListener((ObservableValue<? extends Number> ov, Number oldValue, Number newValue) -> { if (newValue == Number.class.cast(1)) { byImageTab = getByImage(map); byImagePane.setCenter(byImageTab); } else if (newValue == Number.class.cast(0)) { byProfileTab = getByProfile(map, controller.noOfProfiles); byProfilePane.setCenter(byProfileTab); } else { System.out.println("Error this tab has not been created."); } }); } catch (IOException ex) { Logger.getLogger(IPAT_FX.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.boundlessgeo.geoserver.bundle.BundleImporter.java
void loadWorkspace(File wsDir) throws IOException { // WorkspaceInfo ws = depersist(new File(wsDir, "workspace.xml"), WorkspaceInfo.class); // catalog.add(ws); ////from w ww . ja v a2 s . c o m // NamespaceInfo ns = depersist(new File(wsDir, "namespace.xml"), NamespaceInfo.class); // catalog.add(ns); // data directory File dataDir = new File(wsDir, "data"); if (dataDir.exists()) { FileUtils.copyDirectory(dataDir, targetDataDir.get(workspace, "data").dir()); } // styles File styleDir = new File(wsDir, "styles"); if (styleDir.exists()) { loadStyles(styleDir); } //TODO: layer groups // stores for (File dir : wsDir.listFiles(DIRECTORY)) { loadStore(dir, wsDir); } }
From source file:ml.shifu.shifu.core.pmml.PMMLVerifySuit.java
public boolean doVerification() throws Exception { // Step 1. Eval the scores using SHIFU File originModel = new File(this.modelConfigPath); File tmpModel = new File("ModelConfig.json"); File originColumn = new File(this.columnConfigpath); File tmpColumn = new File("ColumnConfig.json"); File modelsDir = new File(this.modelsPath); File tmpModelsDir = new File("models"); FileUtils.copyFile(originModel, tmpModel); FileUtils.copyFile(originColumn, tmpColumn); FileUtils.copyDirectory(modelsDir, tmpModelsDir); // run evaluation set ShifuCLI.runEvalScore(this.evalSetName, null); File evalScore = new File("evals" + File.separator + this.evalSetName + File.separator + "EvalScore"); Map<String, Object> params = new HashMap<String, Object>(); params.put(ExportModelProcessor.IS_CONCISE, this.isConcisePmml); ShifuCLI.exportModel(null, params);// w w w . jav a 2 s . co m // Step 2. Eval the scores using PMML and compare it with SHIFU output String DataPath = this.evalDataPath; String OutPath = "./pmml_out.dat"; for (int index = 0; index < modelCnt; index++) { String num = Integer.toString(index); String pmmlPath = "pmmls" + File.separator + this.modelName + num + ".pmml"; if (ModelTrainConf.ALGORITHM.NN.equals(algorithm)) { evalNNPmml(pmmlPath, DataPath, OutPath, this.delimiter, "model" + num); } else if (ModelTrainConf.ALGORITHM.LR.equals(algorithm)) { evalLRPmml(pmmlPath, DataPath, OutPath, this.delimiter, "model" + num); } else { logger.error("The algorithm - {} is not supported yet.", algorithm); return false; } boolean status = compareScore(evalScore, new File(OutPath), "model" + num, "\\|", this.scoreDiff); if (!status) { return status; } FileUtils.deleteQuietly(new File(OutPath)); } FileUtils.deleteQuietly(tmpModel); FileUtils.deleteQuietly(tmpColumn); FileUtils.deleteDirectory(tmpModelsDir); FileUtils.deleteQuietly(new File("./pmmls")); FileUtils.deleteQuietly(new File("evals")); return true; }
From source file:com.ettrema.http.fs.FsDirectoryResource.java
@Override protected void doCopy(File dest) { try {// ww w .ja va 2s. c om FileUtils.copyDirectory(this.getFile(), dest); } catch (IOException ex) { throw new RuntimeException("Failed to copy to:" + dest.getAbsolutePath(), ex); } }
From source file:edu.harvard.iq.dvn.core.analysis.NetworkDataServiceBean.java
public void initAnalysis(String fileSystemLocation, String sessionId) { try {/* w w w . jav a2 s . c om*/ File fileLocation = new File(fileSystemLocation); String neoDirName = FileUtil.replaceExtension(fileLocation.getName(), NEO4J_EXTENSION); File neoDir = new File(fileLocation.getParent(), neoDirName); // Coy neoDB directory to a temporary location, so this bean can have exclusive access to it. File tempNeoDir = new File(baseTempPath, sessionId + new Long(new Date().getTime()).toString()); tempNeoDir.mkdir(); tempNeoDir.deleteOnExit(); FileUtils.copyDirectory(neoDir, tempNeoDir); // File copyNeoDB = FileUtils. File sqliteFile = new File(fileLocation.getParent(), FileUtil.replaceExtension(fileLocation.getName(), SQLITE_EXTENSION)); try { if (dvnGraphFactory == null) { dvnGraphFactory = new DVNGraphFactory(LIB_PATH); } //dvnGraph = new DVNGraphFactory(LIB_PATH). dvnGraph = dvnGraphFactory.newInstance(tempNeoDir.getAbsolutePath(), sqliteFile.getAbsolutePath(), NEO4J_CONFIG_FILE); //dvnGraph = new DVNGraphImpl(tempNeoDir.getAbsolutePath(), sqliteFile.getAbsolutePath(), NEO4J_CONFIG_FILE); } catch (ClassNotFoundException e) { throw new EJBException(e); } //dvnGraph.initialize(); this.fileSystemLocation = fileSystemLocation; } catch (IOException e) { throw new EJBException(e); } }
From source file:com.aspose.barcode.maven.examples.AsposeExampleSupport.java
public void createExample() { String srcExamplePath = System.getProperty("user.home") + File.separator + localExampleFolder + File.separator + localExampleSourceFolder; String srcExampleResourcePath = System.getProperty("user.home") + File.separator + localExampleFolder + File.separator + localExampleResourceFolder; String destProjectExamplePath = selectedProjectPath + File.separator + localExampleSourceFolder; String destProjectExampleResourcePath = selectedProjectPath + File.separator + localExampleResourceFolder; File srcExampleCategoryPath = new File(srcExamplePath + File.separator + exampleCategory); File destExampleCategoryPath = new File(destProjectExamplePath + File.separator + exampleCategory); Path srcUtil = new File(srcExamplePath + File.separator + "Utils.java").toPath(); Path destUtil = new File(destProjectExamplePath + File.separator + "Utils.java").toPath(); File srcExampleResourceCategoryPath = new File(srcExampleResourcePath + File.separator + exampleCategory); File destExampleResourceCategoryPath = new File( destProjectExampleResourcePath + File.separator + exampleCategory); String repositoryPOM_XML = System.getProperty("user.home") + File.separator + localExampleFolder + File.separator + AsposeConstants.MAVEN_POM_XML; try {// w w w.j a v a 2s . c o m FileUtils.copyDirectory(srcExampleCategoryPath, destExampleCategoryPath); Files.copy(srcUtil, destUtil, StandardCopyOption.REPLACE_EXISTING); FileUtils.copyDirectory(srcExampleResourceCategoryPath, destExampleResourceCategoryPath); NodeList examplesNoneAsposeDependencies = AsposeMavenProjectManager.getInstance() .getDependenciesFromPOM(repositoryPOM_XML, AsposeConstants.ASPOSE_GROUP_ID); AsposeMavenProjectManager.getInstance().addMavenDependenciesInProject(examplesNoneAsposeDependencies); NodeList examplesNoneAsposeRepositories = AsposeMavenProjectManager.getInstance() .getRepositoriesFromPOM(repositoryPOM_XML, AsposeConstants.ASPOSE_MAVEN_REPOSITORY); AsposeMavenProjectManager.getInstance().addMavenRepositoriesInProject(examplesNoneAsposeRepositories); project.refreshLocal(IResource.DEPTH_INFINITE, null); } catch (IOException | CoreException e) { e.printStackTrace(); } }
From source file:com.googlecode.t7mp.steps.ResolveTomcatStep.java
private void copyToTomcatDirectory(final File unpackDirectory) throws IOException { File[] files = unpackDirectory.listFiles(new FileFilter() { @Override// w ww .j a va 2 s . com public boolean accept(final File file) { return file.isDirectory(); } }); // should only be one FileUtils.copyDirectory(files[0], this.configuration.getCatalinaBase()); }
From source file:gr.aueb.mipmapgui.controller.file.ActionSaveMappingTask.java
private void copyTempContents(String saveName, String user) throws IOException { String tempFolderPath = Costanti.SERVER_MAIN_FOLDER + Costanti.SERVER_FILES_FOLDER + user + "/" + Costanti.SERVER_TEMP_FOLDER; File srcDir = new File(tempFolderPath); String destFolderPath = Costanti.SERVER_MAIN_FOLDER + Costanti.SERVER_FILES_FOLDER + user + "/" + saveName; File destDir = new File(destFolderPath); FileUtils.copyDirectory(srcDir, destDir); }
From source file:com.google.gdt.eclipse.designer.gxt.actions.ConfigureExtGwtOperation.java
private void execute0() throws Exception { // ensure jar if (!ProjectUtils.hasType(m_javaProject, "com.extjs.gxt.ui.client.widget.Component")) { String jarPath = getJarPath(m_libraryLocation); if (EnvironmentUtils.isTestingTime()) { ProjectUtils.addExternalJar(m_javaProject, jarPath, null); } else {/* w ww . j av a2s.c o m*/ ProjectUtils.addJar(m_javaProject, jarPath, null); } } // copy resources { File resourcesSourceDir = new File(new File(m_libraryLocation), "resources"); IFolder webFolder = WebUtils.getWebFolder(m_javaProject); File webDir = webFolder.getLocation().toFile(); File resourceTargetDir = new File(webDir, "ExtGWT"); FileUtils.copyDirectory(resourcesSourceDir, resourceTargetDir); webFolder.refreshLocal(IResource.DEPTH_INFINITE, null); } // add elements into module DefaultModuleProvider.modify(m_module, new ModuleModification() { public void modify(ModuleElement moduleElement) throws Exception { moduleElement.addInheritsElement("com.extjs.gxt.ui.GXT"); } }); // add "stylesheet" into HTML { IFile htmlFile = Utils.getHTMLFile(m_module); if (htmlFile != null) { String content = IOUtils2.readString(htmlFile); int linkIndex = content.indexOf("<link type="); if (linkIndex != -1) { String prefix = StringUtilities.getLinePrefix(content, linkIndex); String GXTStylesheet = "<link type=\"text/css\" rel=\"stylesheet\" href=\"ExtGWT/css/gxt-all.css\">"; content = content.substring(0, linkIndex) + GXTStylesheet + SystemUtils.LINE_SEPARATOR + prefix + content.substring(linkIndex); IOUtils2.setFileContents(htmlFile, content); } } } }