List of usage examples for org.apache.commons.io IOUtils toString
public static String toString(byte[] input) throws IOException
byte[]
as a String using the default character encoding of the platform. From source file:de.neofonie.deployer.DeployerMock.java
/** * Read a JSON configuration from the classpath. * * @param name The filename to read from. * @return JsonObject with the configuration. *//*from www . ja v a 2 s. c om*/ public static JsonObject readConfiguration(final String name) { JsonObject result = null; try { InputStream u = DeployerVerticleTest.class.getResourceAsStream(name); assertNotNull(u); result = new JsonObject(IOUtils.toString(u)); } catch (IOException e) { fail(e.getMessage()); } return result; }
From source file:it.geosolutions.opensdi2.workflow.utils.TestUtils.java
public static String readResource(String resourceName) throws IOException { return IOUtils.toString(TestUtils.class.getResource(resourceName).openStream()); }
From source file:com.betfair.cougar.codegen.Files.java
public static String readFile(File a) { try {/* ww w. j a v a2 s . com*/ return IOUtils.toString(new FileReader(a)); } catch (IOException e) { throw new RuntimeException("Error reading file '" + a + "' to string: " + e, e); } }
From source file:com.opengamma.integration.marketdata.manipulator.dsl.ScenarioParametersTest.java
@Test public void setParametersFromScript() throws IOException { String scriptFile = "src/test/groovy/ScenarioParametersTest.groovy"; String script = IOUtils.toString(new BufferedReader(new FileReader(scriptFile))); ScenarioParameters scenarioParameters = new ScenarioDslParameters(script); Map<String, Object> parameters = scenarioParameters.getParameters(); assertEquals("foo", parameters.get("aString")); assertEquals(Lists.newArrayList(1, 2, 3), parameters.get("aList")); assertEquals(1.234, ((Number) parameters.get("aDouble")).doubleValue()); assertEquals(ImmutableMap.of("key1", "value1", "key2", "value2"), parameters.get("aMap")); assertEquals(LocalDate.of(2011, 3, 8), parameters.get("aLocalDate")); }
From source file:com.arvato.thoroughly.filter.FilterRequestWrapper.java
public FilterRequestWrapper(HttpServletRequest request) throws IOException { super(request); body = IOUtils.toString(request.getInputStream()); }
From source file:de.dfki.asr.compass.web.util.ResourceLoader.java
public String getResourceAsString(String resourceName) throws IOException { InputStream resourceStream = getResourceAsStream(resourceName); try {/*ww w.j av a 2 s . c o m*/ return IOUtils.toString(resourceStream); } catch (IOException e) { throw e; } finally { IOUtils.closeQuietly(resourceStream); } }
From source file:io.servicecomb.swagger.generator.core.unittest.UnitTestSwaggerUtils.java
public static String loadExpect(String resPath) { URL url = Thread.currentThread().getContextClassLoader().getResource(resPath); if (url == null) { return "can not found res " + resPath; }/*from ww w . j ava2 s . co m*/ try { return IOUtils.toString(url); } catch (IOException e) { return e.getMessage(); } }
From source file:com.flipkart.flux.api.WorkflowStateSummaryTest.java
@Before public void setUp() throws Exception { objectMapper = new ObjectMapper(); stateSummary = IOUtils.toString(this.getClass().getClassLoader().getResourceAsStream("state_summary.json")); }
From source file:com.flipkart.flux.api.WorkflowStatesDetailTest.java
@Before public void setUp() throws Exception { objectMapper = new ObjectMapper(); statesDetail = IOUtils.toString(this.getClass().getClassLoader().getResourceAsStream("states_detail.json")); }
From source file:gov.nih.nci.ncicb.tcga.dcc.datareports.webservice.PendingUUIDWSFastTest.java
@BeforeClass public static void initStaticResources() throws IOException { InputStream is = new FileInputStream(JSON_PATH + "pending_barcode_sample.json"); pendingUUIDMessage = IOUtils.toString(is); }