List of usage examples for org.apache.commons.io FileUtils copyFileToDirectory
public static void copyFileToDirectory(File srcFile, File destDir) throws IOException
From source file:ch.unibas.charmmtools.generate.inputs.CHARMM_Input.java
private void normalisePathAndCopyFiles() { File parentFile = out.getParentFile(); try {/*from www . ja v a2 s .c o m*/ FileUtils.copyFileToDirectory(new File(cor), parentFile); FileUtils.copyFileToDirectory(new File(top), parentFile); FileUtils.copyFileToDirectory(new File(par), parentFile); if (lpun != null) { FileUtils.copyFileToDirectory(new File(lpun), parentFile); } } catch (IOException ex) { logger.error("Error while copying required files : " + ex); } cor = new File(cor).getName(); top = new File(top).getName(); par = new File(par).getName(); if (lpun != null) { lpun = new File(lpun).getName(); } }
From source file:dao.FilesDaoTest.java
@Before public void setUp() { folder.mkdirs();//from w ww . j a v a2s . c o m File textFolder = new File(folder.toString() + fSeparator + "Texts"); textFolder.mkdirs(); File imageFolder = new File(folder.toString() + fSeparator + "Images" + fSeparator); imageFolder.mkdirs(); String imageSourcePath = System.getProperty("user.dir") + fSeparator + "src" + fSeparator + "test" + fSeparator + "java" + fSeparator + "resources" + fSeparator + "testImg.jpg"; String imageSourcePath2 = System.getProperty("user.dir") + fSeparator + "src" + fSeparator + "test" + fSeparator + "java" + fSeparator + "resources" + fSeparator + "testImg2.jpg"; File sourceImageFolder = new File(imageSourcePath); File sourceImageFolder2 = new File(imageSourcePath2); try { FileUtils.copyFileToDirectory(sourceImageFolder, imageFolder); FileUtils.copyFileToDirectory(sourceImageFolder2, imageFolder); } catch (IOException ex) { Logger.getLogger(FilesDaoTest.class.getName()).log(Level.SEVERE, null, ex); } File textFile = new File(folder.toString() + fSeparator + "Texts" + fSeparator + "textFile.txt"); FileWriter fw = null; BufferedWriter bw = null; try { fw = new FileWriter(textFile); bw = new BufferedWriter(fw); fw.write("textOfTextFile"); if (fw != null) try { fw.close(); } catch (IOException ex) { Logger.getLogger(FilesDaoTest.class.getName()).log(Level.SEVERE, null, ex); } if (bw != null) try { bw.close(); } catch (IOException ex) { Logger.getLogger(FilesDaoTest.class.getName()).log(Level.SEVERE, null, ex); } } catch (IOException ex) { Logger.getLogger(EntryDaoTest.class.getName()).log(Level.SEVERE, null, ex); } File emptyTextFile = new File(folder.toString() + fSeparator + "Texts" + fSeparator + "emptyTextFile.txt"); try { fw = new FileWriter(emptyTextFile); if (fw != null) try { fw.close(); } catch (IOException ex) { Logger.getLogger(FilesDaoTest.class.getName()).log(Level.SEVERE, null, ex); } if (bw != null) try { bw.close(); } catch (IOException ex) { Logger.getLogger(FilesDaoTest.class.getName()).log(Level.SEVERE, null, ex); } } catch (IOException ex) { Logger.getLogger(EntryDaoTest.class.getName()).log(Level.SEVERE, null, ex); } Login.username = "Panagiwtis Georgiadis"; }
From source file:eu.openanalytics.rsb.DirectoryDepositITCase.java
protected void doTestValidZipDeposit(final String jobFileName) throws IOException, InterruptedException, FileNotFoundException { FileUtils.copyFileToDirectory(getTestFile(jobFileName), jobsDirectory); final File acceptedFile = ponderUntilJobAccepted(jobFileName); assertThat("file was not created: " + acceptedFile, acceptedFile.isFile(), is(true)); final File resultFile = ponderUntilJobResult(jobFileName); assertThat("file was not created: " + resultFile, resultFile.isFile(), is(true)); validateZipResult(new FileInputStream(resultFile)); }
From source file:hudson.plugins.mstest.MSTestPublisherJenkinsRuleTest.java
@Test public void testExecuteOnRealTrx() throws InterruptedException, IOException, Exception { EnvironmentVariablesNodeProperty prop = new EnvironmentVariablesNodeProperty(); EnvVars envVars = prop.getEnvVars(); envVars.put("TRX", "results-example-mstest.trx"); j.jenkins.getGlobalNodeProperties().add(prop); FreeStyleProject project = j.createFreeStyleProject(); project.getPublishersList().add(new MSTestPublisher("$WORKSPACE/$TRX")); project.getBuildersList().add(new TestBuilder() { public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException { File f = new File("src/test/resources/hudson/plugins/mstest/results-example-mstest.trx"); assertTrue(f.exists());/* www .j av a 2 s.com*/ File dest = new File(build.getWorkspace().getRemote()); assertTrue(dest.exists()); FileUtils.copyFileToDirectory(f, dest); assertTrue(build.getWorkspace().child("results-example-mstest.trx").exists()); return true; } }); FreeStyleBuild build = project.scheduleBuild2(0).get(); if (build != null) { String s = FileUtils.readFileToString(build.getLogFile()); assertTrue(s.contains(File.separator + "results-example-mstest.trx")); } }
From source file:edu.northwestern.bioinformatics.studycalendar.osgi.plugininstaller.PluginInstallerTest.java
private void deployOutsideBundleAndWait(File deployTo) throws IOException, InterruptedException { FileUtils.copyFileToDirectory(outsideBundleFilename, deployTo); System.out.println("Waiting for " + (WAIT_FOR_FILEINSTALL / 1000.0) + 's'); Thread.sleep(WAIT_FOR_FILEINSTALL); }
From source file:de.uzk.hki.da.cb.CreatePremisActionTests.java
/** * Sets the up.//from w ww. j a v a 2 s . c om * @throws IOException */ @Before public void setUp() throws IOException { FileUtils.copyFileToDirectory(C.PREMIS_XSD_TEST, new File("conf/")); FileUtils.copyFileToDirectory(C.XLINK_XSD_TEST, new File("conf/")); FileUtils.copyFileToDirectory(C.CONTRACT_XSD_TEST, new File("conf/")); Node node = new Node(); node.setWorkAreaRootPath(workAreaRootPath); pkg = new Package(); pkg.setId(1234565); pkg.setDelta(1); pkg.setContainerName("testpackage.tgz"); pkg2 = new Package(); pkg2.setId(1); pkg2.setDelta(2); pkg2.setContainerName("testpackage.tgz"); User contractor = new User(); contractor.setShort_name("TEST"); object = new Object(); object.getPackages().add(pkg); object.getPackages().add(pkg2); object.setIdentifier("identifier"); object.setUrn("urn"); object.setContractor(contractor); FileFormatFacade jhoveScanService = mock(FileFormatFacade.class); action.setFileFormatFacade(jhoveScanService); DAFile a = new DAFile("2013_07_31+11_54+a", "140864.tif"); a.setFormatPUID("fmt/10"); DAFile b = new DAFile("2013_07_31+11_54+b", "140864.tif"); b.setFormatPUID("fmt/10"); DAFile c = new DAFile("2013_07_31+11_54+a", "premis.xml"); c.setFormatPUID("da-fmt/1"); pkg2.getFiles().add(a); pkg2.getFiles().add(b); pkg2.getFiles().add(c); Event e = new Event(); e.setType("CONVERT"); e.setId(1); e.setSource_file(a); e.setTarget_file(b); e.setDetail("this was a conversion"); e.setAgent_type("NODE"); e.setAgent_name("TESTNODE"); e.setDate(new Date()); pkg2.getEvents().add(e); job = new Job(); object.setOrig_name("testpackage"); job.setId(7654321); job.setContainer_extension("tgz"); job.setObject(object); job.setRep_name("2013_07_31+11_54+"); action.setJob(job); action.setLocalNode(node); action.setObject(object); wa = new WorkArea(node, object); action.setWorkArea(wa); }
From source file:com.atlassian.jira.webtests.ztests.ao.TestActiveObjectsRestore.java
private void copyFileToJiraImportDirectory(File file) { File jiraImportDirectory = new File(administration.getJiraHomeDirectory(), "import"); try {/*from ww w.j a v a 2 s . c o m*/ FileUtils.copyFileToDirectory(file, jiraImportDirectory); } catch (IOException e) { throw new RuntimeException("Could not copy file " + file.getAbsolutePath() + " to the import directory in jira home " + jiraImportDirectory, e); } }
From source file:de.uzk.hki.da.cb.UpdateMetadataActionEADTests.java
@Before public void setUp() throws IOException, JDOMException, ParserConfigurationException, SAXException { n.setWorkAreaRootPath(WORK_AREA_ROOT_PATH); mtds = mock(MimeTypeDetectionService.class); when(mtds.identify((File) anyObject(), anyBoolean())).thenReturn("image/tiff"); String[] repNames = { "temp_pips/public", "temp_pips/institution" }; action.setRepNames(repNames);/* w w w .java2s . co m*/ FileUtils.copyFileToDirectory(Path.make(WORK_AREA_ROOT_PATH, "work/src/mets_2_99.xml").toFile(), Path.make(WORK_AREA_ROOT_PATH, "work/TEST/identifier/data", _1_B_REP).toFile()); FileUtils.copyFileToDirectory(Path.make(WORK_AREA_ROOT_PATH, "work/src/vda3.XML").toFile(), Path.make(WORK_AREA_ROOT_PATH, "work/TEST/identifier/data", _1_B_REP).toFile()); DAFile f1 = new DAFile(_1_B_REP, "mets_2_99.xml"); de.uzk.hki.da.model.Document doc1 = new de.uzk.hki.da.model.Document(f1); o.addDocument(doc1); o.getLatestPackage().getFiles().add(f1); DAFile f2 = new DAFile(_1_B_REP, "ALVR_Nr_4547_Aufn_067.tif"); de.uzk.hki.da.model.Document doc2 = new de.uzk.hki.da.model.Document(f2); o.addDocument(doc2); o.getLatestPackage().getFiles().add(f2); DAFile f3 = new DAFile(_1_B_REP, "vda3.XML"); de.uzk.hki.da.model.Document doc3 = new de.uzk.hki.da.model.Document(f3); o.addDocument(doc3); o.getLatestPackage().getFiles().add(f3); f4 = new DAFile(_1_B_REP, "alvr_Nr_4547_Aufn_067.tif"); de.uzk.hki.da.model.Document doc4 = new de.uzk.hki.da.model.Document(f4); o.addDocument(doc4); o.getLatestPackage().getFiles().add(f4); event1 = new Event(); event1.setSource_file(f2); event1.setTarget_file(new DAFile(_TEMP_PIP_REP_PUBLIC, "renamed067.tif")); event1.setType("CONVERT"); o.getLatestPackage().getEvents().add(event1); event2 = new Event(); event2.setSource_file(f2); event2.setTarget_file(new DAFile(_TEMP_PIP_REP_INSTITUTION, "renamed067.tif")); event2.setType("CONVERT"); o.getLatestPackage().getEvents().add(event2); o.setPackage_type("EAD"); o.setMetadata_file("vda3.XML"); HashMap<String, String> xpaths = new HashMap<String, String>(); xpaths.put("METS", "//mets:file"); xpaths.put("EAD", "//daoloc/@href"); action.setXpathsToUrls(xpaths); HashMap<String, String> nsMap = new HashMap<String, String>(); nsMap.put("mets", METS_NS.getURI()); nsMap.put("xlink", XLINK_NS.getURI()); action.setNamespaces(nsMap); action.setMtds(mtds); action.setPresMode(true); ps.setUrisFile("http://data.danrw.de/file"); }
From source file:com.fonoster.astive.server.appmanager.DeployerManager.java
/** * {@inheritDoc}/*from w ww . ja va 2s. co m*/ */ @Override public void deploy(String appPath) throws AstiveException { try { if (LOG.isInfoEnabled()) { LOG.info(AppLocale.getI18n("messageDeployingApp", new Object[] { appPath })); } File srcFile = new File(appPath); File appsFolder = new File(AbstractAstiveServer.ASTIVE_APPS); // The name of the file must be use to undeploy the apps. AstObj app = new AstObj(srcFile.getName(), srcFile.getCanonicalPath()); if (!appExist(app.getDeploymentId())) { addApp(app); File f = new File(AbstractAstiveServer.ASTIVE_APPS + srcFile.getName()); if (!f.exists()) { FileUtils.copyFileToDirectory(srcFile, appsFolder); } } else { LOG.warn(AppLocale.getI18n("errorAppAlreadyExist", new Object[] { appPath, AbstractAstiveServer.ASTIVE_APPS })); return; } if (LOG.isInfoEnabled()) { LOG.info(AppLocale.getI18n("messageAppDeployed", new Object[] { app.getInfo().getName() })); } } catch (IOException ex) { throw new AstiveException(ex); } catch (JclException ex) { throw new AstiveException(ex); } catch (AstiveException ex) { throw new AstiveException(ex); } }
From source file:com.opoopress.maven.plugins.theme.JarMojo.java
@Override public void execute() throws MojoExecutionException, MojoFailureException { String[] includes = { "**/*" }; String[] excludes = { "**/Thumbs.db", "src/**", "target/**", ".config.rb.cache" }; File outputFile = new File(buildDirectory, finalName + "-" + classifier + ".jar"); File jarFile = new File(buildDirectory, finalName + ".jar"); File targetPluginsDir = new File(buildDirectory, "plugins"); try {// ww w . j a va 2 s. com MavenArchiver archiver = new MavenArchiver(); archiver.setArchiver(jarArchiver); archiver.setOutputFile(outputFile); archiver.getArchiver().addDirectory(basedir, includes, excludes); if (outputDirectory.exists() && jarFile.exists()) { if (!targetPluginsDir.exists()) { targetPluginsDir.mkdirs(); } FileUtils.copyFileToDirectory(jarFile, targetPluginsDir); } else { getLog().warn("No theme classes add to theme package."); } if (targetPluginsDir.exists()) { archiver.getArchiver().addDirectory(buildDirectory, new String[] { "plugins/**" }, null); } archiver.createArchive(project, archive); } catch (Exception e) { throw new MojoExecutionException("build archiver error: " + e.getMessage(), e); } if (attach) { projectHelper.attachArtifact(project, "jar", classifier, outputFile); } }