List of usage examples for org.apache.commons.io FileUtils readFileToString
public static String readFileToString(File file, String encoding) throws IOException
From source file:com.liferay.ide.gradle.core.parser.GradleDependencyUpdater.java
public GradleDependencyUpdater(File file) throws IOException, MultipleCompilationErrorsException { this(FileUtils.readFileToString(file, "UTF-8")); _file = file;// w w w.j a v a 2 s . co m }
From source file:com.talent.balance.conf.BackendConf.java
public static BackendConf getInstance() { if (instance == null) { synchronized (log) { if (instance == null) { try { instance = JsonWrap.toBean( FileUtils.readFileToString(new File("./conf/backend-conf.json"), "utf-8"), BackendConf.class); } catch (Exception e) { log.error("", e); throw new RuntimeException(e); }/* w ww. j a v a2 s . co m*/ } } } return instance; }
From source file:eu.project.ttc.readers.TxtCollectionReader.java
@Override protected String getDocumentText(String absPath, String encoding) throws IOException { return FileUtils.readFileToString(new File(absPath), encoding); }
From source file:de.tudarmstadt.ukp.dkpro.examples.nameannotation.NameAnnotationPipelineTest.java
@Test public void test() throws Exception { NameAnnotationPipeline.main(new String[] {}); assertEquals(FileUtils.readFileToString(EXPECTED_OUTPUT, ENCODING).trim(), FileUtils.readFileToString(OUTPUT_FILE, ENCODING).trim()); }
From source file:hu.bme.mit.trainbenchmark.benchmark.rdf4j.queries.Rdf4jQuery.java
public Rdf4jQuery(final TRdf4jDriver driver, final String workspaceDir, final RailwayQuery query) throws IOException { super(driver, workspaceDir, query); this.queryDefinition = FileUtils.readFileToString(new File(queryPath), Charset.forName("UTF-8")); }
From source file:net.ion.radon.cload.readers.FileResourceReader.java
public byte[] getBytes(final String pResourceName) { try {/* w w w .ja v a2 s. c om*/ return FileUtils.readFileToString(new File(root, pResourceName), "UTF-8").getBytes(); } catch (Exception e) { return null; } }
From source file:com.github.stagirs.docextractor.wiki.WikiDocProcessorTest.java
@Test public void test2() throws IOException { WikiDocProcessor processor = new WikiDocProcessor(); Document doc = processor.processDocument("", FileUtils.readFileToString(new File("src/test/resources/???"), "utf-8")); assertEquals(doc.getPoints().size(), 120); }
From source file:com.puzzle.module.send.excutor.MessageSendExcutor.java
public void excute(File xml) { KafkaProducerClient client = null;/* ww w.j ava 2s . c om*/ try { String content = FileUtils.readFileToString(xml, "UTF-8"); XmlCheckResult checkResult = xmlCheck.isValid(content); if (!checkResult.isValid) {// FileUtils.copyFileToDirectory(xml, new File(FileDto.getSingleInstance().errorPath), true); log.error(xml.getAbsolutePath() + ""); return; } boolean tr = true; if (content.indexOf("<CEB625Message") != -1 || content.indexOf("<CEB623Message") != -1 || content.indexOf("<CEB711Message") != -1 || content.indexOf("<CEB513Message") != -1) {//? String signedXml = SignXml.sign2(content); if (signedXml == null || signedXml.equals("")) { return; } File signFile = new File(FileDto.getSingleInstance().fileSignPath, "???-" + DateUtil.getCurrDateMM2() + xml.getName()); FileUtils.writeStringToFile(signFile, signedXml, "UTF-8"); if (FileDto.getSingleInstance().sendCusisSelected) { client = KafkaProducerClient.getSingletonInstance(); client.send(FileDto.getSingleInstance().cusSendTopic, signedXml); QueueUtils.sendSignTable.offer(new JtableMessageDto(signFile.getAbsolutePath(), DateUtil.getFormatDateTime(new Date()))); log.info(xml.getName() + "???"); } } else { String splitXml = SpliteXml.splite(content); if (splitXml == null) { return; } log.info(xml.getName() + ""); splitXml = SignXml.sign(splitXml);// ???? if (splitXml == null) { log.info("?>>>>??"); return; } File signFile = new File(FileDto.getSingleInstance().fileSignPath, "???-" + DateUtil.getCurrDateMM2() + xml.getName()); FileUtils.writeStringToFile(signFile, splitXml, "UTF-8"); // if (FileDto.getSingleInstance().sendCusisSelected) { client = KafkaProducerClient.getSingletonInstance(); client.send(FileDto.getSingleInstance().cusSendTopic, splitXml); QueueUtils.sendSignTable.offer(new JtableMessageDto(signFile.getAbsolutePath(), DateUtil.getFormatDateTime(new Date()))); log.info(xml.getName() + "???"); } if (FileDto.getSingleInstance().sendCiqisSelected) { client = KafkaProducerClient.getSingletonInstance(); client.send(FileDto.getSingleInstance().sendTpoic, content);//??? QueueUtils.sendTable1.offer( new JtableMessageDto(xml.getAbsolutePath(), DateUtil.getFormatDateTime(new Date()))); log.info(xml.getName() + "???"); } } } catch (Exception e) { e.printStackTrace(); if (client != null) { client.close(); } } }
From source file:namedatabasescraper.PageScraper.java
@SuppressWarnings("OverridableMethodCallInConstructor") public PageScraper(File file, String dirname, String selector, String charset) throws IOException { filename = file.getAbsolutePath();// w w w . j av a 2 s .c o m this.dirname = dirname; this.id = this.createScraperId(); String html = FileUtils.readFileToString(file, charset); this.names = new ArrayList<>(); Document soup = Jsoup.parse(html); //Elements nameElements = soup.select("a.nom"); //Elements nameElements = soup.select("div > a:not(.n1)"); Elements nameElements = soup.select(selector); for (Element nameElement : nameElements) { String name = nameElement.text(); names.add(name); } logger.log(Level.INFO, "Scraped " + this.names.size() + " names from page {0}", file.getName()); }
From source file:com.napkindrawing.dbversion.loader.fs.FileSystemRevisionLoader.java
@Override public Revision loadRevision(String profileName, Version version) { File revisionFile = getRevisionFile(profileName, version); Revision revision = new Revision(version); if (revisionFile.getName().length() > 10) { // Strip out version prefix and ".sql" suffix revision.setName(revisionFile.getName().substring(6, revisionFile.getName().length() - 4)); }/*w w w . j a v a 2 s. c om*/ try { revision.setUpgradeScriptTemplate(FileUtils.readFileToString(revisionFile, "UTF-8")); revision.assignUpgradeScriptTemplateChecksum(); } catch (IOException e) { throw new RuntimeException("Error reading upgrade script", e); } return revision; }