List of usage examples for org.apache.commons.io FileUtils touch
public static void touch(File file) throws IOException
From source file:com.selventa.whistle.cli.Rcr.java
private boolean touchFile(boolean valid, File f) { boolean touchOk = true; try {// w w w.ja v a 2 s . co m FileUtils.touch(f); } catch (IOException e) { touchOk = false; } if (!touchOk || !f.canWrite()) { System.err.println( "ERROR: Could not open file for " + "writing. Do you have permission to write the file here?"); valid = false; } return valid; }
From source file:net.sf.taverna.t2.workbench.ui.impl.UserRegistrationForm.java
protected void remindMeLater() { try {/* w w w. jav a 2s . co m*/ FileUtils.touch(remindMeLaterFile); } catch (IOException ioex) { logger.error("Failed to touch the 'Remind me later' file at user registration.", ioex); } closeDialog(); }
From source file:net.sf.taverna.t2.workbench.ui.impl.UserRegistrationForm.java
protected void doNotRegister() { try {/*w w w .java 2s .com*/ FileUtils.touch(doNotRegisterMeFile); if (remindMeLaterFile.exists()) remindMeLaterFile.delete(); } catch (IOException ioex) { logger.error("Failed to touch the 'Do not register me' file at user registration.", ioex); } closeDialog(); }
From source file:de.fosd.jdime.artifact.file.FileArtifact.java
/** * Creates an empty version of the {@link #file} on disk. * * @throws IOException// w w w . jav a 2 s .c o m * see {@link FileUtils#touch(File)} */ private void touchFile() throws IOException { FileUtils.touch(file); }
From source file:com.websqrd.catbot.setting.CatbotSettings.java
public static void initSite(String site) { //schema//from ww w.j a v a 2 s . c om String contents = "<site name=\"" + site + "\" version=\"1.0\">" + LINE_SEPARATOR + "</catbot>"; String configFile = getSiteKey(site, siteConfigFilename); FileOutputStream writer = null; try { writer = new FileOutputStream(configFile); writer.write(contents.getBytes()); } catch (IOException e) { logger.error(e.getMessage(), e); } finally { try { writer.close(); } catch (IOException e) { //ignore } } //make inc info file configFile = getSiteKey(site, incInfoFilename); try { FileUtils.touch(new File(configFile)); } catch (IOException e) { logger.error(e.getMessage(), e); } }
From source file:com.ikanow.aleph2.analytics.services.TestAnalyticsContext.java
@Test public void test_fileLocations() throws InstantiationException, IllegalAccessException, ClassNotFoundException, InterruptedException, ExecutionException { _logger.info("running test_fileLocations"); try {/*from ww w.j ava 2 s . c om*/ final AnalyticsContext test_context = _app_injector.getInstance(AnalyticsContext.class); //All we can do here is test the trivial eclipse specific path: try { File f = new File(test_context._globals.local_root_dir() + "/lib/aleph2_test_file_locations.jar"); FileUtils.forceMkdir(f.getParentFile()); FileUtils.touch(f); } catch (Exception e) { } // probably already exists: final List<String> lib_paths = test_context.getAnalyticsContextLibraries(Optional .of(ImmutableSet.<Tuple2<Class<? extends IUnderlyingService>, Optional<String>>>builder() .add(Tuples._2T(IStorageService.class, Optional.<String>empty())).build())); //(this doesn't work very well when run in test mode because it's all being found from file) assertTrue("Finds some libraries", !lib_paths.isEmpty()); lib_paths.stream().forEach(lib -> assertTrue("No external libraries: " + lib, lib.contains("aleph2"))); assertTrue( "Can find the test JAR or the data model: " + lib_paths.stream().collect(Collectors.joining(";")), lib_paths.stream().anyMatch(lib -> lib.contains("aleph2_test_file_locations")) || lib_paths.stream().anyMatch(lib -> lib.contains("aleph2_data_model"))); // Now get the various shared libs final AnalyticThreadJobBean analytic_job1 = BeanTemplateUtils.build(AnalyticThreadJobBean.class) .with(AnalyticThreadJobBean::analytic_technology_name_or_id, "test_analytic_tech_id") .with(AnalyticThreadJobBean::library_names_or_ids, Arrays.asList("id1", "name2.zip")).done() .get(); final AnalyticThreadJobBean analytic_job2 = BeanTemplateUtils.build(AnalyticThreadJobBean.class) .with(AnalyticThreadJobBean::analytic_technology_name_or_id, "test_analytic_tech_id_XXX") // (not actually possible, just for tesT) .with(AnalyticThreadJobBean::library_names_or_ids, Arrays.asList("id1", "name3.test", "test_analytic_tech_id")) .done().get(); final DataBucketBean test_bucket = BeanTemplateUtils.build(DataBucketBean.class) .with(DataBucketBean::_id, "test") .with(DataBucketBean::analytic_thread, BeanTemplateUtils.build(AnalyticThreadBean.class) .with(AnalyticThreadBean::jobs, Arrays.asList(analytic_job1, analytic_job2)) .done().get()) .done().get(); final SharedLibraryBean atlib1 = BeanTemplateUtils.build(SharedLibraryBean.class) .with(SharedLibraryBean::_id, "test_analytic_tech_id") .with(SharedLibraryBean::path_name, "test_analytic_tech_name.jar").done().get(); final SharedLibraryBean atmod1 = BeanTemplateUtils.build(SharedLibraryBean.class) .with(SharedLibraryBean::_id, "id1").with(SharedLibraryBean::path_name, "name1.jar").done() .get(); final SharedLibraryBean atmod2 = BeanTemplateUtils.build(SharedLibraryBean.class) .with(SharedLibraryBean::_id, "id2").with(SharedLibraryBean::path_name, "name2.zip").done() .get(); final SharedLibraryBean atmod3 = BeanTemplateUtils.build(SharedLibraryBean.class) .with(SharedLibraryBean::_id, "id3").with(SharedLibraryBean::path_name, "name3.test").done() .get(); test_context._service_context.getService(IManagementDbService.class, Optional.empty()).get() .getSharedLibraryStore().storeObjects(Arrays.asList(atlib1, atmod1, atmod2, atmod3)).get(); Map<String, String> mods = test_context .getAnalyticsLibraries(Optional.of(test_bucket), Arrays.asList(analytic_job1, analytic_job2)) .get(); assertTrue("name1", mods.containsKey("name1.jar") && mods.get("name1.jar").endsWith("id1.cache.jar")); assertTrue("name2", mods.containsKey("name2.zip") && mods.get("name2.zip").endsWith("id2.cache.zip")); assertTrue("name3", mods.containsKey("name3.test") && mods.get("name3.test").endsWith("id3.cache.misc.test")); assertTrue("test_analytic_tech_name", mods.containsKey("test_analytic_tech_name.jar") && mods.get("test_analytic_tech_name.jar").endsWith("test_analytic_tech_id.cache.jar")); } catch (Exception e) { try { e.printStackTrace(); } catch (Exception ee) { System.out.println(ErrorUtils.getLongForm("{1}: {0}", e, e.getClass())); } fail("Threw exception"); } }
From source file:com.dell.asm.asmcore.asmmanager.app.AsmManagerApp.java
private boolean isRestartAfterApplianceUpdate() { File applianceUpdate = new File("/opt/Dell/ASM/temp/asm.update"); if (!applianceUpdate.exists()) { _logger.debug("Creating the appliance update file."); try {/* w ww .j a v a 2 s . c o m*/ FileUtils.touch(applianceUpdate); } catch (Exception e) { String msg = "Unable to create the appliance update file: " + e.getMessage(); _logger.error(msg, e); } return true; } else { return false; } }
From source file:de.tor.tribes.ui.windows.DSWorkbenchMainFrame.java
@Override public void setVisible(boolean v) { logger.info("Setting MainWindow visible"); if (GlobalOptions.isMinimal()) { getContentPane().remove(jPanel4); getContentPane().add(infoPanel, BorderLayout.SOUTH); setSize(530, 200);/* w ww. ja va 2 s . c o m*/ setPreferredSize(new Dimension(530, 200)); setMinimumSize(new Dimension(530, 200)); setMaximumSize(new Dimension(1900, 200)); } super.setVisible(v); final boolean vis = v; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { setupRibbon(); if (vis) { //only if set to visible //start ClipboardWatch ClipboardWatch.getSingleton(); //draw map the first time refreshMap(); showReminder(); if (!GlobalOptions.isMinimal() && !Boolean.parseBoolean(GlobalOptions.getProperty("no.welcome"))) { setGlassPane(new WelcomePanel()); getGlassPane().setVisible(true); } else { glasspaneVisible = false; } } } }); File runningIndicator = new File(".running"); if (runningIndicator.exists()) { showRestoreOption(); } else { try { FileUtils.touch(new File(".running")); } catch (IOException ioe) { logger.error("Failed to touch file '.running'", ioe); } } }
From source file:hydrograph.ui.parametergrid.dialog.MultiParameterFileDialog.java
private void createNewParamterFile(String file) throws IOException { FileUtils.touch(new File(file)); }
From source file:com.ikanow.aleph2.data_import_manager.analytics.actors.TestAnalyticsTriggerWorkerActor.java
protected void createDirectory(final String root_dir, final String bucket_path, final String suffix, int files_to_create, boolean clear_dir) throws IOException { final String dir = root_dir + File.separator + bucket_path + File.separator + suffix; final File dir_file = new File(dir); if (clear_dir) { try {//from ww w . java 2 s . c o m FileUtils.deleteDirectory(dir_file); } catch (Exception e) { } // prob just doesn't exist } try { FileUtils.forceMkdir(dir_file); } catch (Exception e) { // prob just already exists } assertTrue("Directory should exist: " + dir_file, dir_file.exists()); for (int ii = 0; ii < files_to_create; ++ii) { final String file = dir + UuidUtils.get().getRandomUuid() + ".json"; final File file_file = new File(file); FileUtils.touch(file_file); assertTrue("Newly created file should exist", file_file.exists()); //System.out.println("Created file in " + dir + ": " + file + " .. " + file_file.lastModified()); } }