List of usage examples for org.apache.commons.io FileUtils readFileToString
public static String readFileToString(File file) throws IOException
From source file:ifpb.pod.proj.appdata.gerenciador.TXTNotificacao.java
public String recuperarByToken(String token) throws IOException { File fl = new File(this.getClass().getResource("/msg/").getFile(), token + ".txt"); System.out.println("file: " + fl.getAbsolutePath() + " existe?: " + fl.exists()); return FileUtils.readFileToString(fl); }
From source file:controllers.TemplateController.java
public static void importTemplate(Project project, File file) throws IOException { String data = FileUtils.readFileToString(file); Template importedTemplate = new Gson().fromJson(data, Template.class); Template newTemplate = project.addTemplate(importedTemplate.name); for (TemplateAttribute attr : importedTemplate.attributes) { TemplateAttribute newAttr = newTemplate.addAttribute(attr.name, attr.description, attr.hidden); newAttr.sort = attr.sort;// w ww . j a va 2 s.co m newAttr.save(); } jsonOk(); }
From source file:gov.nih.nci.cacis.ip.mirthconnect.XDSNavChannelMCIntegrationTest.java
@Test public void invokeXDSNavChannel() throws Exception { final URL url = getClass().getClassLoader().getResource("CMP_sample_soap.xml"); String messageXml = FileUtils.readFileToString(new File(url.toURI())); final Node res = invoke(CanonicalModelProcessorMCIntegrationTest.ADDRESS, SoapTransportFactory.TRANSPORT_ID, messageXml.getBytes());//from ww w . j ava 2 s . c om assertNotNull(res); addNamespace("ns2", "http://cacis.nci.nih.gov"); assertValid("//ns2:caCISResponse[@status='SUCCESS']", res); }
From source file:core.Operator.java
public Operator(String source) { String user = ""; try {/*from www . j av a2s.com*/ user = FileUtils.readFileToString(new File("Operators\\" + source + ".asdp")); } catch (Exception e) { System.out.print(e); } String[] info = user.split("#"); for (int i = 0; i < info.length; i++) { if (info[i].equals("oName")) { i++; setName(info[i]); } else if (info[i].equals("oFunc")) { i++; setFunc(info[i]); } else if (info[i].equals("oPhone")) { i++; setTel(info[i]); } else if (info[i].equals("oMail")) { i++; setMail(info[i]); } else if (info[i].equals("oSek")) { i++; setSektion(info[i]); } else { } } }
From source file:com.aionemu.gameserver.configs.schedule.SiegeSchedule.java
public static SiegeSchedule load() { SiegeSchedule ss;/*w w w . j ava 2 s .co m*/ try { String xml = FileUtils.readFileToString(new File("./config/schedule/siege_schedule.xml")); ss = JAXBUtil.deserialize(xml, SiegeSchedule.class); } catch (Exception e) { throw new RuntimeException("Failed to initialize Sieges", e); } return ss; }
From source file:integration.AbstractCompileIT.java
protected void testCompile(File lessFile, File cssFile) throws Exception { String expected = FileUtils.readFileToString(cssFile); String actual = lessCompiler.compile(lessFile); assertEquals(expected.replace("\r\n", "\n"), actual); }
From source file:com.semicolonapps.onepassword.OnePasswordKeychain.java
public void decrypt(Item item) throws Exception { File contentFile = new File(baseDir, "data/default/" + item.getId() + ".1password"); JSONObject content = new JSONObject(new JSONTokener(FileUtils.readFileToString(contentFile))); RawContent rawContent = new RawContent(content); byte[] key = getEncryptionKeyFor(rawContent.getSecurityLevel()); byte[] decrypted = new Aes().decrypt(rawContent.getAttribute("encrypted"), key); rawContent.setDecryptedData(new String(decrypted)); item.setContent(rawContent);//from w w w. ja v a 2 s . c o m }
From source file:elaborate.editor.export.mvn.MVNValidatorTest.java
@Test public void testValidation() throws IOException { String tei = FileUtils.readFileToString(new File("src/test/resources/validatortest.xml")); ValidationResult result = MVNValidator.validateTEI(tei); Log.info("result={}", result); assertThat(result.isValid()).isTrue(); assertThat(result.getMessage()).isEmpty(); }
From source file:net.geoprism.sidebar.JSONMenuProvider.java
public ArrayList<MenuItem> getMenu() { try {/*w ww .ja va 2 s . c o m*/ String json = FileUtils.readFileToString(new File(ConfigurationManager .getResource(ConfigurationManager.ConfigGroup.ROOT, "geoprism/sidebar.txt").getPath())); return this.toMenu(new JSONArray(json)); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.sangupta.codefix.RemoveCopyright.java
@Override protected String processEachFile(File file) throws IOException { // read contents String contents = FileUtils.readFileToString(file).trim(); // check if file contains comments or not boolean hasCopyright = CopyrightHelper.checkCopyrightExists(contents); if (!hasCopyright) { return "no copyright detected"; }//from ww w . j a va 2s. c om // find the ending location int index = CopyrightHelper.findCopyrightEnd(contents); if (index == -1) { return "no proper end to comment detected, skipping!"; } contents = contents.substring(index + 1); FileUtils.writeStringToFile(file, contents); return "copyright removed!"; }