List of usage examples for org.apache.commons.io FileUtils copyFile
public static void copyFile(File srcFile, File destFile) throws IOException
From source file:de.uzk.hki.da.action.ActionRegistryTests.java
/** * Sets the up.//w w w .jav a 2 s . co m * @throws IOException */ @Before public void setUp() throws IOException { FileUtils.copyFile(new File("src/main/conf/config.properties.dev"), new File("conf/config.properties")); context = new FileSystemXmlApplicationContext( "src/test/resources/action/ActionRegistryTests/action-definitions.xml"); registry = (ActionRegistry) context.getBean("actionRegistry"); }
From source file:com.googlecode.t7mp.steps.CopySetenvScriptStep.java
@Override public void execute(Context context) { File tomcatConfigDirectory = context.getConfiguration().getTomcatConfigDirectory(); if (tomcatConfigDirectory == null || !tomcatConfigDirectory.exists()) { return;/*from ww w .j a va 2 s . c o m*/ } File tomcatDirectory = tomcatConfigDirectory.getParentFile(); File tomcatBinDirectory = new File(tomcatDirectory, "/bin/"); File[] setEnvFiles = tomcatBinDirectory.listFiles(new FileFilter() { @Override public boolean accept(File file) { return (file.isFile() && file.getName().startsWith(PREFIX)); } }); // listFiles returns null if binDirectory does not exist // https://github.com/t7mp/t7mp/issues/28 if (setEnvFiles != null) { for (File scriptFile : setEnvFiles) { try { FileUtils.copyFile(scriptFile, new File(TomcatUtil.getBinDirectory(context.getConfiguration().getCatalinaBase()), scriptFile.getName())); } catch (IOException e) { throw new TomcatSetupException(e.getMessage(), e); } } } }
From source file:com.galenframework.reports.model.FileTempStorage.java
public void copyAllFilesTo(File dir) throws IOException { for (Map.Entry<String, File> entry : files.entrySet()) { FileUtils.copyFile(entry.getValue(), new File(dir.getAbsolutePath() + File.separator + entry.getKey())); }/* ww w . j a v a 2 s . c o m*/ for (FileTempStorage storage : childStorages) { storage.copyAllFilesTo(dir); } }
From source file:com.buddycloud.mediaserver.delete.DeleteAvatarTest.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); }/* ww w . j a v a2s . co m*/ fileToDelete = new File(destDir + File.separator + MEDIA_ID); FileUtils.copyFile(new File(TEST_FILE_PATH + TEST_AVATAR_NAME), fileToDelete); Media media = buildMedia(MEDIA_ID, TEST_FILE_PATH + TEST_AVATAR_NAME); dataSource.storeMedia(media); dataSource.storeAvatar(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:com.datatorrent.contrib.enrich.FileEnrichmentTest.java
@Test public void testEnrichmentOperator() throws IOException, InterruptedException { URL origUrl = this.getClass().getResource("/productmapping.txt"); URL fileUrl = new URL(this.getClass().getResource("/").toString() + "productmapping1.txt"); FileUtils.deleteQuietly(new File(fileUrl.getPath())); FileUtils.copyFile(new File(origUrl.getPath()), new File(fileUrl.getPath())); MapEnricher oper = new MapEnricher(); FSLoader store = new JsonFSLoader(); store.setFileName(fileUrl.toString()); oper.setLookupFields(Arrays.asList("productId")); oper.setIncludeFields(Arrays.asList("productCategory")); oper.setStore(store);//from w w w . j ava2 s . co m oper.setup(null); /* File contains 6 entries, but operator one entry is duplicate, * so cache should contains only 5 entries after scanning input file. */ //Assert.assertEquals("Number of mappings ", 7, oper.cache.size()); CollectorTestSink<Map<String, Object>> sink = new CollectorTestSink<>(); @SuppressWarnings({ "unchecked", "rawtypes" }) CollectorTestSink<Object> tmp = (CollectorTestSink) sink; oper.output.setSink(tmp); oper.activate(null); oper.beginWindow(0); Map<String, Object> tuple = Maps.newHashMap(); tuple.put("productId", 3); tuple.put("channelId", 4); tuple.put("amount", 10.0); Kryo kryo = new Kryo(); oper.input.process(kryo.copy(tuple)); oper.endWindow(); oper.deactivate(); /* Number of tuple, emitted */ Assert.assertEquals("Number of tuple emitted ", 1, sink.collectedTuples.size()); Map<String, Object> emitted = sink.collectedTuples.iterator().next(); /* The fields present in original event is kept as it is */ Assert.assertEquals("Number of fields in emitted tuple", 4, emitted.size()); Assert.assertEquals("value of productId is 3", tuple.get("productId"), emitted.get("productId")); Assert.assertEquals("value of channelId is 4", tuple.get("channelId"), emitted.get("channelId")); Assert.assertEquals("value of amount is 10.0", tuple.get("amount"), emitted.get("amount")); /* Check if productCategory is added to the event */ Assert.assertEquals("productCategory is part of tuple", true, emitted.containsKey("productCategory")); Assert.assertEquals("value of product category is 1", 5, emitted.get("productCategory")); Assert.assertTrue(emitted.get("productCategory") instanceof Integer); }
From source file:com.buddycloud.mediaserver.delete.DeleteMediaTest.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); }/*from ww w . j a v a2s .c o m*/ fileToDelete = new File(destDir + File.separator + MEDIA_ID); FileUtils.copyFile(new File(TEST_FILE_PATH + TEST_IMAGE_NAME), fileToDelete); 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:net.fabricmc.installer.installer.LocalVersionInstaller.java
public static void installServer(File mcDir, IInstallerProgress progress) throws Exception { JFileChooser fc = new JFileChooser(); fc.setDialogTitle(Translator.getString("install.client.selectCustomJar")); fc.setFileFilter(new FileNameExtensionFilter("Jar Files", "jar")); if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { File inputFile = fc.getSelectedFile(); JarFile jarFile = new JarFile(inputFile); Attributes attributes = jarFile.getManifest().getMainAttributes(); String fabricVersion = attributes.getValue("FabricVersion"); jarFile.close();// w w w .ja v a2 s . c o m File fabricJar = new File(mcDir, "fabric-" + fabricVersion + ".jar"); if (fabricJar.exists()) { fabricJar.delete(); } FileUtils.copyFile(inputFile, fabricJar); ServerInstaller.install(mcDir, fabricVersion, progress, fabricJar); } else { throw new Exception("Failed to find jar"); } }
From source file:mesclasses.util.FileSaveUtil.java
public static File createBackupFile() { FileConfigurationManager conf = FileConfigurationManager.getInstance(); if (!saveFileExists()) { return null; }// w w w . j ava2 s.c o m File bckFile = new File( conf.getBackupDir() + File.separator + FileConfigurationManager.DEFAULT_SAVE_FILE_NAME + "_" + LocalDate.now().format(Constants.DATE_FORMATTER) + ".xml"); try { if (bckFile.exists()) { bckFile.delete(); } FileUtils.copyFile(getSaveFile(), bckFile); LOG.info("Fichier de sauvegarde " + bckFile.getName() + " cr"); } catch (Exception e) { AppLogger.notif("Impossible de crer le fichier de sauvegarde", e); } File[] bckFiles = new File(conf.getBackupDir()).listFiles(); if (bckFiles.length >= 8) { bckFiles[0].delete(); } return bckFile; }
From source file:ml.shifu.shifu.core.validator.ModelInspectorTest.java
@BeforeClass public void setUp() throws IOException { File originalModel = new File( "src/test/resources/example/cancer-judgement/ModelStore/ModelSet1/ModelConfig.json"); File originalColumn = new File( "src/test/resources/example/cancer-judgement/ModelStore/ModelSet1/ColumnConfig.json"); modelFile = new File("ModelConfig.json"); columnFile = new File("ColumnConfig.json"); FileUtils.copyFile(originalModel, modelFile); FileUtils.copyFile(originalColumn, columnFile); instance = ModelInspector.getInspector(); }
From source file:net.sourceforge.atunes.misc.TempFolder.java
/** * Copies a file to temp folder./*from ww w .j av a2s . c om*/ * * @param srcFile * the src file * * @return File object to copied file in temp folder */ public File copyToTempFolder(File srcFile) { File destFile = new File(StringUtils.getString(SystemProperties.getTempFolder(), SystemProperties.FILE_SEPARATOR, srcFile.getName())); try { FileUtils.copyFile(srcFile, destFile); } catch (IOException e) { return null; } return destFile; }