List of usage examples for org.apache.commons.io IOUtils toString
public static String toString(byte[] input, String encoding) throws IOException
byte[]
as a String using the specified character encoding. From source file:de.onyxbits.raccoon.gplay.VersionWorker.java
@Override protected Version doInBackground() throws Exception { InputStream in = null;/*from w w w.j a va 2 s . c o m*/ try { in = Bookmarks.LATEST.toURL().openStream(); return new Version(IOUtils.toString(in, "UTF-8").trim()); } catch (Exception e) { // Not important enough to make a fuss about. // e.printStackTrace(); } try { in.close(); } catch (Exception e) { } return new Version("0.0.0"); }
From source file:com.github.ltyk.wro4j.services.BaseTest.java
protected static String getClasspathFile(String file) throws IOException { return IOUtils.toString(BaseTest.class.getClassLoader().getResourceAsStream(file), "UTF-8"); }
From source file:de.perdian.commons.lang.conversion.impl.converters.ResourceToCharSequenceConverter.java
@Override public CharSequence convert(Resource resource) { if (resource == null) { return null; } else {//w w w . j a v a2s .c o m try { try (InputStream resourceStream = resource.getInputStream()) { return IOUtils.toString(resourceStream, "UTF-8"); } } catch (IOException e) { throw new ConverterException(resource, "Cannot read data from Resource", e); } } }
From source file:edworld.pdfreader4humans.PDFReaderTest.java
@Test public void toXML() throws IOException { assertEquals(IOUtils.toString(getClass().getResource("/testcase1/output.xml"), UTF_8), reader.toXML()); }
From source file:com.twosigma.beakerx.kernel.magic.command.PomFactory.java
public String createPom(Params params) throws IOException { InputStream pom = getClass().getClassLoader().getResourceAsStream(MavenJarResolver.POM_XML); String pomAsString = IOUtils.toString(pom, StandardCharsets.UTF_8); pomAsString = configureOutputDir(params.pathToMavenRepo, pomAsString); pomAsString = configureDependencies(params.dependencies, pomAsString); pomAsString = configureRepos(params.repos, pomAsString); pomAsString = configureGoal(params.goal, pomAsString); pomAsString = configureBuildClasspathPlugin(params.pathToMavenRepo, params.mavenBuiltClasspathFileName, pomAsString);/* ww w .j a v a2s .c o m*/ return pomAsString; }
From source file:de.christian_klisch.software.servercheck.GeneralTest.java
@Test public void testCommandline() { System.out.println(CommandView.class.toString()); try {//from w w w .j a v a2 s.c o m Process p = Runtime.getRuntime().exec("echo 0"); System.out.println(IOUtils.toString(p.getInputStream(), "UTF-8")); } catch (IOException e) { e.printStackTrace(); } assertTrue(true); }
From source file:com.luoo.mywork.modules.act.rest.editor.main.StencilsetRestResource.java
@RequestMapping(value = "/act/service/editor/stencilset", method = RequestMethod.GET, produces = "application/json;charset=utf-8") public String getStencilset() { InputStream stencilsetStream = this.getClass().getClassLoader().getResourceAsStream("stencilset.json"); try {/*from w w w . j av a2 s . c o m*/ return IOUtils.toString(stencilsetStream, "utf-8"); } catch (Exception e) { throw new ActivitiException("Error while loading stencil set", e); } }
From source file:com.rodrigodev.xgen4j_table_generator.test.common.StringUtils.java
public static String fromInputStream(InputStream anInputStream) { return unchecked(() -> IOUtils.toString(anInputStream, StandardCharsets.UTF_8)); }
From source file:fi.aluesarjat.prototype.AreasServlet.java
public AreasServlet() { try {/*www . ja v a2 s . c om*/ areas = IOUtils.toString(getResourceAsStream("/areas.json"), "UTF-8"); areas1 = IOUtils.toString(getResourceAsStream("/area1.json"), "UTF-8"); areas2 = IOUtils.toString(getResourceAsStream("/area2.json"), "UTF-8"); areas3 = IOUtils.toString(getResourceAsStream("/area3.json"), "UTF-8"); areas4 = IOUtils.toString(getResourceAsStream("/area4.json"), "UTF-8"); } catch (IOException e) { throw new IllegalStateException(e); } }
From source file:com.github.neilprosser.cjson.CJSONTest.java
public static String fromFile(String path) { try {/*from w w w .j a v a2s. c o m*/ return IOUtils.toString(CJSONTest.class.getClassLoader().getResourceAsStream(path), "UTF-8"); } catch (IOException e) { throw new RuntimeException(e); } }