List of usage examples for java.io File getAbsoluteFile
public File getAbsoluteFile()
From source file:com.javacreed.apps.mail.Model.java
public void loadData(final File dataFile) throws IOException { this.currentDataFile = dataFile.getAbsoluteFile(); setData(FileUtils.readFileToString(dataFile, "UTF-8")); }
From source file:gridool.dht.DefaultLocalDirectory.java
public DefaultLocalDirectory(@CheckForNull LockManager lockManger) { super(lockManger); DbCollection rootColl = DbCollection.getRootCollection(); File colDir = rootColl.getDirectory(); assert (colDir.exists()) : colDir.getAbsoluteFile(); File idxFile = new File(colDir, DIR_IDX_NAME); this.btree = new BIndexFile(idxFile, true); }
From source file:de.doering.dwca.clemens.ChecklistBuilder.java
public File build() throws IOException { // new writer File dwcaDir = FileUtils.createTempDir("clemens-", ""); File dwcaZip = new File(dwcaDir.getAbsoluteFile() + ".zip"); log.info("Writing archive files to temporary folder " + dwcaDir); writer = new DwcaWriter(DwcTerm.Taxon, dwcaDir); // metadata/*from ww w . j a v a 2s .co m*/ Eml eml = new Eml(); eml.setTitle(TITLE); Citation cite = new Citation(); cite.setCitation(CITATION); eml.setCitation(cite); eml.setDescription(DESCRIPTION); eml.setLanguage(LANGUAGE); eml.setHomepageUrl(HOMEPAGE); eml.setLogoUrl(LOGO); org.gbif.metadata.eml.Agent contact = new org.gbif.metadata.eml.Agent(); contact.setOrganisation(CONTACT_ORG); contact.setEmail(CONTACT_EMAIL); eml.setContact(contact); // parse file and some metadata parseData(); // finish archive and zip it log.info("Bundling archive at {}", dwcaZip); writer.setEml(eml); writer.finalize(); // compress CompressionUtil.zipDir(dwcaDir, dwcaZip); // remove temp folder org.apache.commons.io.FileUtils.deleteDirectory(dwcaDir); log.info("Dwc archive completed at {} !", dwcaZip); return dwcaZip; }
From source file:de.thischwa.pmcms.livecycle.C5MessageResolverImpl.java
@Override public void setServletContext(ServletContext servletContext) throws RuntimeException { Path fileSystemPath = new Path(PropertiesLoader.getFilemanagerPath()); fileSystemPath.addFolder(langPath);// ww w. j av a 2 s . c o m File msgFolder = new File(Constants.APPLICATION_DIR, fileSystemPath.toString()); if (!msgFolder.exists()) throw new RuntimeException( String.format("C5 scripts folder couldn't be found: %s", msgFolder.getAbsolutePath())); logger.debug(String.format("try to resolve lang-data from dir: %s", msgFolder.getAbsolutePath())); ObjectMapper mapper = new ObjectMapper(); try { for (File file : msgFolder.listFiles(jsFilter)) { String lang = FilenameUtils.getBaseName(file.getName()); logger.debug(String.format(" - found: %s", file.getAbsoluteFile())); @SuppressWarnings("unchecked") Map<String, String> langData = mapper.readValue(file, Map.class); collectLangData(lang, langData); } } catch (Exception e) { throw new RuntimeException(e); } }
From source file:common.Parameters.java
public Parameters() { PropertiesConfiguration config;//from w w w.ja v a2 s .c o m File file = new File(Constants.LOG4J_PATH); if (!file.getAbsoluteFile().exists()) { log.error("Invalid log properties file!"); System.exit(1); } file = new File(Constants.OBJECT_REPOSITORY_PATH); if (!file.getAbsoluteFile().exists()) { log.error("Invalid Object properties file!"); System.exit(1); } // BasicConfigurator.configure(); PropertyConfigurator.configure(Constants.LOG4J_PATH); try { config = new PropertiesConfiguration(Constants.CONFIG_PATH); config.getSubstitutor().setEnableSubstitutionInVariables(true); setConfig(config); checkConfig(); } catch (ConfigurationException e) { log.error("Unable to load config. Config file possibly missing." + e); System.exit(1); } }
From source file:com.moneydance.modules.features.importlist.io.DeleteOneOperation.java
@Override public void execute(final List<File> files) { final File file = files.iterator().next(); // ESCA-JAVA0166: IOException, SecurityException try {/* w w w .j a va 2s .c o m*/ LOG.info(String.format("Deleting file %s", file.getAbsoluteFile())); FileUtils.forceDelete(file); } catch (Exception e) { // $codepro.audit.disable caughtExceptions LOG.log(Level.WARNING, e.getMessage(), e); final String errorMessage = this.localizable.getErrorMessageDeleteFile(file.getName()); final Object errorLabel = new JLabel(errorMessage); JOptionPane.showMessageDialog(null, // no parent component errorLabel, null, // no title JOptionPane.ERROR_MESSAGE); } }
From source file:com.meltmedia.cadmium.blackbox.test.GitBareRepoInitializer.java
public void init(String repoPath, String sourceDir, String sourceConfigDir) throws Exception { File repoDir = new File(repoPath); if (repoDir.exists()) { FileUtils.forceDelete(repoDir);//w w w . ja va 2 s . com } File checkoutDir = new File(repoDir.getAbsoluteFile().getParent(), repoDir.getName() + ".checkout"); if (checkoutDir.exists()) { FileUtils.forceDelete(checkoutDir); } checkoutPath = checkoutDir.getAbsolutePath(); InitCommand init = Git.init(); init.setBare(true); init.setDirectory(repoDir); bareRepo = init.call(); clonedGit = GitService.cloneRepo(repoPath, checkoutPath); clonedGit.checkinNewContent(sourceConfigDir, "Initial commit"); clonedGit.push(false); clonedGit.newEmtpyRemoteBranch("cd-master"); clonedGit.switchBranch("cd-master"); clonedGit.checkinNewContent(sourceDir, "Initial commit"); clonedGit.push(false); clonedGit.newEmtpyRemoteBranch("cfg-master"); clonedGit.switchBranch("cfg-master"); clonedGit.checkinNewContent(sourceConfigDir, "Initial commit"); clonedGit.push(false); }
From source file:eu.crisis_economics.abm.simulation.injection.TestFromFileNumercialModelParameter.java
/** * Test whether an instance of {@link FromFileTimeseriesParameter} correctly * reads, and correctly reports, a timeseries from a datafile. This unit test * operates as follows:<br><br> * //w w w . ja v a 2s . c om * {@code (a)} * A temporary file {@code F}, named {@code "./paramter-test.dat"} is created * in the local directory;<br> * {@code (b)} * {@code F} is populated with a short discrete subsequence from the expression * {@code f(T) = T**2};<br> * {@code (c)} * {@code F} is parsed by an instance of {@link FromFileTimeseriesParameter};<br> * {@code (d)} * An {@link EmptySimulation} is run for {@code 10} cycles. At each cycle, * it is asserted that the {@link ModelParameter} yields the same expression * {@code f(T)} as is indicated by {@code F}.<br><br> * * For convenience {@code F} is not deleted at the end of the above session. */ @Test public void testReadModelParameterTimeSeriesFromFile() { final double[] expectedX = new double[] { 2., 3., 4., 5., 6., }, expectedY = new double[] { 4., 9., 16., 25., 36., }; final String fileName = "./paramter-test.dat"; try { final File file = new File(fileName); if (!file.exists()) file.createNewFile(); final FileWriter stream = new FileWriter(file.getAbsoluteFile()); final BufferedWriter writer = new BufferedWriter(stream); for (int i = 0; i < expectedX.length; ++i) writer.write(expectedX[i] + "\t" + expectedY[i] + "\n"); writer.close(); stream.close(); } catch (final IOException e) { Assert.fail(); } ModelParameter<Double> parameter = null; try { parameter = new FromFileTimeseriesParameter(fileName, "[name]", new SplineInterpolator()); } catch (final IOException e) { Assert.fail(); } Simulation.repeat(this, "sample", CustomSimulationCycleOrdering.create(0.), parameter, expectedX, expectedY); while (Simulation.getTime() < 10.0) state.schedule.step(state); }
From source file:net.cpollet.jixture.fixtures.TestFileFixture.java
@Test public void getInputStreamReturnsInputStreamFromPath() throws IOException { // GIVEN//from w ww . jav a 2 s .c om File file = folder.newFile("foo.txt"); FileUtils.writeStringToFile(file, "someContent"); String filePath = file.getAbsoluteFile().getAbsolutePath(); FileFixture fileFixture = buildFixture(filePath); // WHEN InputStream actualInputStream = fileFixture.getInputStream(); // THEN InputStream expectedInputStream = new FileInputStream(filePath); compareInputStreams(actualInputStream, expectedInputStream); }
From source file:net.cpollet.jixture.fixtures.TestFileFixture.java
@Test public void getExtractionResultReturnCorrectEntities() throws IOException { // GIVEN/*from w w w . jav a 2 s . c o m*/ File file = folder.newFile("foo.txt"); FileUtils.writeStringToFile(file, "someContent"); String filePath = file.getAbsoluteFile().getAbsolutePath(); FileFixture fileFixture = buildFixture(filePath); fileFixture.addExtractorMatcher(ExtractorMatcher.create(new IsAnything())); fileFixture.populateExtractionResult(Arrays.<Object>asList("string1", "string2")); // WHEN ExtractionResult extractionResult = fileFixture.getExtractionResult(); // THEN assertThat(extractionResult.getEntities()).containsOnly("string1", "string2"); }