List of usage examples for org.apache.commons.io FileUtils readFileToString
public static String readFileToString(File file) throws IOException
From source file:eu.impact_project.iif.tw.tmpl.Code.java
/** * Constructs a Code object from a template file * @param templateFilePath the strin path to the template file * @throws IOException//from w w w . java2 s .c o m */ public Code(String templateFilePath) throws IOException { ctx = new VelocityContext(); this.code = FileUtils.readFileToString(new File(templateFilePath)); }
From source file:com.norconex.committer.core.FileDeleteOperation.java
/** * Constructor.//from w w w . j av a 2 s .co m * @param refFile the file to be deleted */ public FileDeleteOperation(File refFile) { super(); this.refFile = refFile; try { this.reference = FileUtils.readFileToString(refFile); } catch (IOException e) { throw new CommitterException("Cannot obtain reference from file " + refFile, e); } }
From source file:it.geosolutions.geoserver.decoder.MetadataDecoderTest.java
@Test public void testMetadataDimensionInfo() throws IOException { File coverageFile = new ClassPathResource("testdata/coverageExample.xml").getFile(); String coverageString = FileUtils.readFileToString(coverageFile); RESTCoverage coverage = RESTCoverage.build(coverageString); List<RESTDimensionInfo> list = coverage.getDimensionInfo(); Assert.assertEquals(list.size(), 2); for (RESTDimensionInfo el : list) { if (el.getKey().equals("time")) { Assert.assertEquals(el.getResolution(), null); Assert.assertEquals(el.getPresentation(), "LIST"); Assert.assertEquals(el.getKey(), "time"); Assert.assertEquals(el.isEnabled(), true); }/* ww w . j a v a 2 s . c o m*/ if (el.getKey().equals("elevation")) { Assert.assertEquals(el.getResolution(), "2"); Assert.assertEquals(el.getPresentation(), "DISCRETE_INTERVAL"); Assert.assertEquals(el.getKey(), "elevation"); Assert.assertEquals(el.isEnabled(), true); } } }
From source file:com.nubits.nubot.utils.VersionInfo.java
/** * read current git branch within a git repository * * @return/* w ww. j a va 2s. c om*/ */ private static String getCurrentgitBranch() { //get current git branch try { String fp = System.getProperty("user.dir") + "/" + ".git" + "/" + "HEAD"; File f = new File(fp); if (f.exists()) { String s = FileUtils.readFileToString(f); s = s.replace("ref: refs/heads/", ""); s = s.replace("\n", ""); return "develop:branch-" + s; } } catch (Exception e) { ; } return "error"; }
From source file:de.beyondjava.jsf.ajax.differentialContextWriter.differenceEngine.PrimeFacesCheckboxTest.java
/** * Tests what happens when a PrimeFaces SelectBoolean has been checked. * /*from w ww .ja v a 2s . c om*/ * @throws IOException */ @Test public void testDetermineNecessaryChanges3() throws IOException { final DiffenceEngine diffenceEngine = new DiffenceEngine(); File dir = new File("src/test/resources/DifferenceEngine"); final File partialChange = new File(dir, "partialChange3.xml"); if (partialChange.exists()) { String newHTML = FileUtils.readFileToString(partialChange); String lastKnownHTML = FileUtils.readFileToString(new File(dir, "html3.xml")); HTMLTag lastKnownCorrespondingNode = new HTMLTag(lastKnownHTML); List<String> deletions = new ArrayList<>(); List<String> attributeChanges = new ArrayList<>(); List<String> insertions = new ArrayList<>(); List<HTMLTag> updates = new ArrayList<>(); diffenceEngine.determineNecessaryChanges(newHTML, lastKnownCorrespondingNode, updates, deletions, attributeChanges, insertions); assertNotNull(updates); assertEquals(0, updates.size()); assertEquals(1, deletions.size()); assertEquals(3, attributeChanges.size()); } }
From source file:hu.bme.mit.trainbenchmark.benchmark.sql.benchmarkcases.SQLChecker.java
public SQLChecker(final SQLDriver driver, final BenchmarkConfig bc) throws IOException, SQLException { super();// w ww. ja v a 2s . c om this.driver = driver; this.query = bc.getQuery(); final String queryPath = bc.getWorkspacePath() + driver.getResourceDirectory() + "queries/" + bc.getQuery() + ".sql"; this.queryDefinition = FileUtils.readFileToString(new File(queryPath)); }
From source file:de.tudarmstadt.ukp.dkpro.tc.features.readability.AvgLengthExtractorTest.java
@Test public void testAvgLengthExtractor() throws Exception { String text = FileUtils.readFileToString(new File("src/test/resources/test_document_en.txt")); AnalysisEngineDescription desc = createEngineDescription(createEngineDescription(OpenNlpSegmenter.class), createEngineDescription(OpenNlpPosTagger.class)); AnalysisEngine engine = createEngine(desc); JCas jcas = engine.newJCas();/*from w w w .j a v a2 s . co m*/ jcas.setDocumentLanguage("en"); jcas.setDocumentText(text); engine.process(jcas); AvgLengthExtractor extractor = new AvgLengthExtractor(); List<Feature> features = extractor.extract(jcas); Assert.assertEquals(3, features.size()); Assert.assertEquals(features.get(0).getName(), "AvgSentenceLength"); Assert.assertEquals(features.get(1).getName(), "AvgWordLengthInCharacters"); Assert.assertEquals(features.get(2).getName(), "AvgWordLengthInSyllables"); Assert.assertEquals((double) features.get(0).getValue(), 17.2, 0.1); Assert.assertEquals((double) features.get(1).getValue(), 4.7, 0.1); Assert.assertEquals((double) features.get(2).getValue(), 1.4, 0.1); }
From source file:edu.ku.brc.specify.tools.l10nios.L10NUIIndexer.java
/** * @param file//from www. ja v a 2 s . com */ public void load(final File file) { try { contents = FileUtils.readFileToString(file); } catch (IOException e) { e.printStackTrace(); } }
From source file:gov.nih.nci.cacis.cdw.CDWLoaderSystemTest.java
@Test public void xmlToRDFLoad() throws Exception { final org.openrdf.model.URI context = con.getRepository().getValueFactory() .createURI(loader.generateContext()); File xslF = new File(getClass().getClassLoader().getResource("caCISRequestSample3.xml").toURI()); String xmlString = FileUtils.readFileToString(xslF); loader.load(xmlString, context.toString(), GRPH_GROUP_STUDY_ID, GRPH_GROUP_SITE_ID, GRPH_GROUP_P1_ID); final String query = QUERY_PFX + context + QUERY_END; final Value[][] results = doTupleQuery(con, query); assertTrue(results.length > 0);// w w w .j av a 2 s. c o m }
From source file:com.pinterest.deployservice.common.DBConfigReader.java
public DBConfigReader() throws Exception { dbJson = FileUtils.readFileToString(new File(MYSQL_GEN_ZK)); credJson = FileUtils.readFileToString(new File(AUTH_FILE)); }