List of usage examples for org.apache.commons.io FileUtils touch
public static void touch(File file) throws IOException
From source file:com.qcadoo.plugin.internal.filemanager.PluginFileManagerTest.java
@Before public void init() throws IOException { source = folder.newFolder("source"); destination = folder.newFolder("destination"); pluginTmpFile = new File(source, "pluginname.jar"); FileUtils.touch(pluginTmpFile); defaultPluginFileManager = new DefaultPluginFileManager(); defaultPluginFileManager.setPluginsPath(destination.getAbsolutePath()); defaultPluginFileManager.setPluginsTmpPath(source.getAbsolutePath()); }
From source file:ca.weblite.xmlvm.XMLVMTest.java
@Test public void testSomeMethod() throws IOException { org.apache.tools.ant.Project proj = new org.apache.tools.ant.Project(); File basedir = new File("/Volumes/Windows VMS/NetbeansProjects/HelloWorldCN1"); proj.setBasedir(basedir.getAbsolutePath()); XMLVM xmlvm = new XMLVM(); xmlvm.setProject(proj);/*from w w w . j av a 2 s .co m*/ File dest = new File(basedir, "cout"); dest.mkdir(); Path src = new Path(proj, new File(basedir, "src").getAbsolutePath()); xmlvm.setSrc(src); xmlvm.setDest(dest); File buildDir = new File(basedir, "build"); buildDir = new File(buildDir, "classes"); xmlvm.setJavaBuildDir(buildDir); File iOSPort = new File(basedir, "iOSPort"); Path classPath = new Path(proj); classPath.add(new Path(proj, buildDir.getAbsolutePath())); src.add(new Path(proj, new File("/Volumes/Windows VMS/src/codenameone-read-only/CodenameOne/src").getAbsolutePath())); src.add(new Path(proj, new File(iOSPort, "src").getAbsolutePath())); xmlvm.setClassPath(classPath); xmlvm.setTarget("c"); //xmlvm.doCleanBuild(); //if ( true ) return; File myApp = new File(basedir, "src/com/mycompany/myapp/MyApplication.java"); FileUtils.touch(myApp); System.out.println("Doing regular build now"); xmlvm.doRegularBuild(); }
From source file:com.screenslicer.common.Config.java
private Config() { File file = new File("./screenslicer.config"); String basicAuthUserTmp = null; String basicAuthPassTmp = null; String secretATmp = null;//from ww w . jav a 2 s . c o m String secretBTmp = null; String secretCTmp = null; String secretDTmp = null; String mandrillKeyTmp = null; String mandrillEmailTmp = null; try { FileUtils.touch(file); props.load(new FileInputStream(file)); basicAuthUserTmp = props.getProperty("basic_auth_user", Random.next()); basicAuthPassTmp = props.getProperty("basic_auth_pass", Random.next()); secretATmp = props.getProperty("secret_a", Random.next()); secretBTmp = props.getProperty("secret_b", Random.next()); secretCTmp = props.getProperty("secret_c", Random.next()); secretDTmp = props.getProperty("secret_d", Random.next()); mandrillKeyTmp = props.getProperty("mandrill_key"); mandrillEmailTmp = props.getProperty("mandrill_email"); props.store(new FileOutputStream(new File("./screenslicer.config")), null); } catch (Throwable t) { Log.exception(t); } basicAuthUser = basicAuthUserTmp; basicAuthPass = basicAuthPassTmp; secretA = secretATmp; secretB = secretBTmp; secretC = secretCTmp; secretD = secretDTmp; mandrillKey = mandrillKeyTmp; mandrillEmail = mandrillEmailTmp; }
From source file:com.comcast.cats.configuration.CatsLogger.java
private void placeLogFileinCatsHome(File destFile) { byte[] store = new byte[1024]; OutputStream os = null;// w ww .j ava 2 s. c o m InputStream is = getClass().getResourceAsStream("/cats-logging.xml"); try { FileUtils.touch(destFile); os = new FileOutputStream(destFile); int c; while ((c = is.read(store, 0, store.length)) != -1) { os.write(store, 0, c); } logger.info("Log configuration file is placed in to location: " + destFile.getPath()); } catch (IOException e) { logger.error("Error placing log configuration file in to catshome: " + e); } finally { try { if (null != is) { is.close(); } if (null != os) { os.close(); } } catch (IOException e) { logger.error("Error closing input/ouptput stream: " + e); } } }
From source file:com.orange.mmp.dao.flf.MidletDaoFlfImpl.java
public Midlet createOrUdpdate(Midlet midlet) throws MMPDaoException { if (midlet == null || midlet.getJadLocation() == null || midlet.getJarLocation() == null || midlet.getType() == null) { throw new MMPDaoException("missing or bad data access object"); }// w w w .j a va 2 s.c o m try { this.lock.lock(); File typeFolder = new File(this.path, midlet.getType()); if (!typeFolder.isDirectory()) FileUtils.forceMkdir(typeFolder); File jadFile = new File(new URI(midlet.getJadLocation())); FileUtils.copyFileToDirectory(jadFile, typeFolder); File jarFile = new File(new URI(midlet.getJarLocation())); FileUtils.copyFileToDirectory(jarFile, typeFolder); FileUtils.touch(new File(this.path)); } catch (IOException ioe) { throw new MMPDaoException("failed to add PFM : " + ioe.getMessage()); } catch (URISyntaxException use) { throw new MMPDaoException("failed to add PFM : " + use.getMessage()); } finally { this.lock.unlock(); } return midlet; }
From source file:net.lmxm.ute.executers.tasks.FileSystemDeleteTaskExecuterTest.java
/** * Test delete files directory contents. *//*w w w . j a va 2 s . com*/ @Test public void testDeleteFilesDirectoryContents() { try { final File directory = new File(TMP_DIR, "TESTDIRECTORY"); directory.deleteOnExit(); directory.mkdir(); final File file = new File(directory, "UTE.TEST"); file.deleteOnExit(); FileUtils.touch(file); assertTrue(file.exists()); final FileReference fileReference = new FileReference(); fileReference.setName("UTE.TEST"); final List<FileReference> files = new ArrayList<FileReference>(); files.add(fileReference); executer.deleteFiles(directory.getAbsolutePath(), files, STOP_ON_ERROR); assertFalse(file.exists()); } catch (final IOException e) { fail(); } }
From source file:com.leverno.ysbos.harvest.HarvesterTest.java
private void createTestStructure() { rootFolder = new String("/tmp/archiverTest/"); subFolder = String.format("%s/sub", rootFolder); fileOne = new File(String.format("%s/one", rootFolder)); fileTwo = new File(String.format("%s/two", subFolder)); try {/*from w w w . j a v a2 s. c o m*/ FileUtils.forceMkdir(new File(subFolder)); FileUtils.touch(fileOne); FileUtils.touch(fileTwo); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.comcast.cats.PropertyUtil.java
protected void loadPropertiesFromFile() throws IOException { File catsPropsFile = new File(TEST_PROPERTIES_FILE); FileUtils.touch(catsPropsFile); this.load(new FileInputStream(catsPropsFile)); }
From source file:de.blizzy.documentr.util.UtilTest.java
@Test(expected = None.class) public void deleteQuietly() throws IOException { File dir = tempDir.getRoot(); File file = new File(dir, "test.txt"); //$NON-NLS-1$ FileUtils.touch(file); // check that file actually exists assertTrue(file.isFile());//from w ww. jav a 2 s .c o m Util.deleteQuietly(file); assertFalse(file.exists()); Util.deleteQuietly(dir); assertFalse(dir.exists()); }
From source file:com.ning.metrics.collector.hadoop.processing.TestHadoopWriterFactory.java
private void testProcessLeftBelowFilesAllClean() throws Exception { final HadoopWriterFactory factory = new NoWriteHadoopWriterFactory(null, config); FileUtils.touch(new File(lockDirectory.getPath() + "/some_file_which_should_be_sent_1")); FileUtils.touch(new File(lockDirectory.getPath() + "/some_file_which_should_be_sent_2")); FileUtils.touch(new File(quarantineDirectory.getPath() + "/some_other_file_which_should_be_sent")); Assert.assertEquals(FileUtils/*from www . j a v a 2s . c om*/ .listFiles(spoolDirectory, FileFilterUtils.trueFileFilter(), FileFilterUtils.trueFileFilter()) .size(), 3); Assert.assertTrue(spoolDirectory.exists()); Assert.assertTrue(tmpDirectory.exists()); Assert.assertTrue(lockDirectory.exists()); Assert.assertTrue(quarantineDirectory.exists()); Thread.sleep(2 * CUTOFF_TIME); factory.processLeftBelowFiles(); // All files should have been sent Assert.assertFalse(spoolDirectory.exists()); Assert.assertFalse(tmpDirectory.exists()); Assert.assertFalse(lockDirectory.exists()); Assert.assertFalse(quarantineDirectory.exists()); // We could even test the mapping in HDFS here (with the keys) Assert.assertEquals(hdfs.values().size(), 3); }