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.birbit.jsonapi.TestUtil.java
static String readTestData(String name) throws IOException { return FileUtils.readFileToString(new File("test-data/" + name), Charsets.UTF_8); }
From source file:ca.weblite.jdeploy.impl.MavenDeploy.java
public Element getPomRoot() { if (pomRoot == null) { try {// w ww . j a va2 s . com String pomStr = FileUtils.readFileToString(pom, "UTF-8"); XMLParser p = new XMLParser(); pomRoot = p.parse(new StringReader(pomStr)); } catch (IOException ex) { Logger.getLogger(MavenDeploy.class.getName()).log(Level.SEVERE, null, ex); throw new RuntimeException(ex); } } return pomRoot; }
From source file:com.google.reducisaurus.JsCompressorTest.java
private String readFileToString(String filename) throws Exception { File file = new File(filename); return FileUtils.readFileToString(file, "UTF-8"); }
From source file:dhr.uploadtomicrobit.MicrobitFirmware.java
static String getFirmware() { String str = ""; String userFirmware = Preferences.get("dhr.uploadtomicrobit.firmware"); if (userFirmware.length() > 0) { File firmwareFile = new File(userFirmware); if (firmwareFile.exists() && !firmwareFile.isDirectory()) { try { str = FileUtils.readFileToString(firmwareFile, "UTF-8"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace();/* ww w . java 2 s . c o m*/ } } } return str; // Return either the correct firmaware or nothing at all }
From source file:io.github.bluemarlin.util.BluemarlineUtil.java
public static String readFileToString(File file) { String raw = ""; try {//from w ww .j a v a 2 s . com raw = FileUtils.readFileToString(file, "UTF-8"); } catch (IOException e) { throw new BlackmarketRuntimeException(e); } return raw; }
From source file:de.micromata.genome.tpsb.httpmockup.testbuilder.HttpSectionParserTest.java
@Test public void testParseHttpScenario() { try {//w ww .ja va 2s . c o m String content = FileUtils.readFileToString(new File("./dev/extrc/tests/httpmockup/HttpScenario1.txt"), "UTF-8"); HttpScenario scen = new HttpScenario(content); MockHttpServletRequest req = scen.getRequest(); final StringWriter sw = new StringWriter(); IOUtils.copy(req.getReader(), sw); String s = sw.toString(); s.length(); } catch (Exception ex) { throw new RuntimeException(ex); } }
From source file:com.thoughtworks.go.config.GoConfigFileReader.java
public String configXml() throws IOException { return FileUtils.readFileToString(fileLocation(), UTF_8); }
From source file:br.usp.poli.lta.cereda.macro.util.CommonUtils.java
/** * Obtm o contedo a partir do caminho informado. * @param path Caminho a ser pesquisado. * @return Contedo do caminho informado. * @throws TextRetrievalException Um erro ocorreu ao obter o arquivo. */// www . ja v a2 s. co m public static String get(String path) throws TextRetrievalException { try { // cria uma nova URL e obtm o fluxo de bytes URL url = new URL(path); InputStream stream = url.openStream(); // cria um arquivo temporrio, copia o fluxo de bytes para ele, l // o contedo e remove o arquivo temporrio File temp = new File( System.getProperty("user.home").concat(java.io.File.separator).concat("get-tmp.txt")); FileUtils.copyInputStreamToFile(stream, temp); String output = FileUtils.readFileToString(temp, Charset.forName("UTF-8")); temp.delete(); // retorna o contedo return output; } catch (MalformedURLException mue) { // a URL invlida, lanar exceo throw new TextRetrievalException("A URL informada invlida."); } catch (IOException ioe) { // o documento no foi encontrado, lanar exceo throw new TextRetrievalException("O documento informado na URL no foi encontrado."); } }
From source file:com.github.stagirs.docextractor.wiki.WikiDocProcessorTest.java
@Test public void test1() throws IOException { WikiDocProcessor processor = new WikiDocProcessor(); Document doc = processor.processDocument("", FileUtils.readFileToString(new File("src/test/resources/"), "utf-8")); assertEquals(doc.getPoints().size(), 119); }
From source file:com.opensymphony.webwork.util.classloader.readers.FileResourceReader.java
public char[] getContent(final String fileName) { try {// ww w .j av a2 s .c om return FileUtils.readFileToString(new File(base, fileName), "UTF-8").toCharArray(); } catch (Exception e) { } return null; }