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:com.centurylink.cloud.sdk.core.client.errors.ClcHttpClientException.java
private static String responseBody(ClientResponseContext response) throws IOException { return IOUtils.toString(response.getEntityStream(), "UTF-8"); }
From source file:com.refreshsf.contrib.client.tests.ResourceUtil.java
public static String readResourceFile(String fileName, String encoding) throws IOException { return IOUtils.toString(getResourceInputStream(fileName), encoding); }
From source file:design.process.ProcessUtil.java
/***/ public static String executeResult(final File workDir, final String... termArray) throws IOException, InterruptedException { final Process process = executeProcess(workDir, termArray); final String input = IOUtils.toString(process.getInputStream(), "UTF-8"); final String error = IOUtils.toString(process.getErrorStream(), "UTF-8"); final String result = input + error; return result; }
From source file:io.logspace.hq.webapp.mode.DemoHqMode.java
public static Order loadOrder(String path, String controllerId) { try {//from w w w . j a v a 2 s . c o m Order order = new Order(); order.setId("order_" + controllerId); order.setLastModified(new Date()); order.setContent( IOUtils.toString(DemoHqMode.class.getResource(path + controllerId + ".json"), "UTF-8")); return order; } catch (IOException e) { throw new InitializationFailedException("Could not store demo order.", e); } }
From source file:iox.refused.util.TextUtil.java
public static String loadfile(ServletContext context, String filename) { InputStream is = context.getResourceAsStream(filename); if (is == null) { logger.log(Level.SEVERE, "<loadfile> unable to load " + filename); return ""; }/* w w w. java 2 s . co m*/ String data; try { data = IOUtils.toString(is, CS); } catch (IOException e) { logger.log(Level.SEVERE, "<loadfile> unable to load " + filename, e); data = ""; } IOUtils.closeQuietly(is); return data; }
From source file:net.es.nsi.common.util.ContentType.java
public static String decode2String(String contentType, InputStream is) throws IOException { if (XGZIP.equalsIgnoreCase(contentType)) { return IOUtils.toString(new GZIPInputStream(is), Charset.defaultCharset()); } else {/*from w w w .ja v a 2s. c om*/ return IOUtils.toString(is, Charset.defaultCharset()); } }
From source file:io.wcm.maven.plugins.i18n.FileUtil.java
public static String getStringFromClasspath(String resourcePath) throws IOException { try (InputStream is = FileUtil.class.getClassLoader().getResourceAsStream(resourcePath)) { return IOUtils.toString(is, CharEncoding.UTF_8); }//from w w w . j a v a2s .c o m }
From source file:de.arraying.arraybot.util.UScript.java
/** * Gets the contents of a URL.//from ww w .j a v a 2 s . c o m * @param url The URL. * @return The value. */ public static String valueOf(String url) { try { return IOUtils.toString(new URL(url), Charset.forName("utf-8")); } catch (IOException exception) { exception.printStackTrace(); return ""; } }
From source file:com.flipkart.zjsonpatch.JsonDiffTest.java
@BeforeClass public static void beforeClass() throws IOException { String path = "/testdata/sample.json"; InputStream resourceAsStream = JsonDiffTest.class.getResourceAsStream(path); String testData = IOUtils.toString(resourceAsStream, "UTF-8"); jsonNode = (ArrayNode) objectMapper.readTree(testData); }
From source file:com.flipkart.zjsonpatch.JsonDiffTest2.java
@BeforeClass public static void beforeClass() throws IOException { String path = "/testdata/diff.json"; InputStream resourceAsStream = JsonDiffTest.class.getResourceAsStream(path); String testData = IOUtils.toString(resourceAsStream, "UTF-8"); jsonNode = (ArrayNode) objectMapper.readTree(testData); }