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:be.solidx.hot.test.nio.http.EchoPOSTServlet.java
protected void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws ServletException, IOException { resp.setContentType(req.getContentType()); resp.setContentLength(req.getContentLength()); String body = IOUtils.toString(req.getInputStream()); System.out.println(body);/*from w w w . j a v a 2 s . c o m*/ resp.getWriter().write(body); }
From source file:com.hybris.datahub.core.services.impl.AbstractScriptFragmentTest.java
protected String readContentFromTheInputStream() throws IOException { return IOUtils.toString(fragment.getContentAsInputStream()); }
From source file:net.lshift.diffa.assets.JstTemplatesPreProcessor.java
public void process(Resource resource, Reader input, Writer output) throws IOException { if (resource.getUri().endsWith(".jst")) { String content = IOUtils.toString(input); String name = removeSuffix(removePrefix(resource.getUri(), "/js/templates/"), ".jst"); output.write("window.JST = (window.JST || {});\n"); output.write(String.format("window.JST['%s'] = _.template(\n", name)); List<String> result = new ArrayList<String>(); for (String l : content.split("\n")) { result.add("\"" + StringEscapeUtils.escapeJava(l) + "\""); }//from w w w .ja v a2s . c o m output.write(StringUtils.join(result.iterator(), " + \n")); output.write(");\n"); } else { IOUtils.copy(input, output); } }
From source file:edu.vt.cs.irwin.etdscraper.service.HttpClientPageFetcher.java
/** * {@inheritDoc}/*from w w w . jav a 2 s.c om*/ */ @Override public String getPageContents(String url) throws IOException { HttpGet get = new HttpGet(url); HttpResponse response = client.execute(get); return IOUtils.toString(response.getEntity().getContent()); }
From source file:be.fedict.eid.pkira.crypto.csr.CSRInfoTest.java
private CSRInfo readCSRFromResource(String resource) throws IOException, CryptoException { InputStream input = getClass().getResourceAsStream(resource); String csr = IOUtils.toString(input); return new CSRParserImpl().parseCSR(csr); }
From source file:io.apicurio.hub.core.beans.TestOpenApiDocumentIO.java
/** * Test method for {@link io.apicurio.hub.core.beans.OpenApiDocument#OpenApiDocument()}. *///from w w w .jav a2 s . co m @Test public void testOpenApiDocument() throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); URL contentUrl = getClass().getResource("simple-api-3.0.json"); String content = IOUtils.toString(contentUrl); OpenApi3Document document = mapper.readerFor(OpenApi3Document.class).readValue(content); Assert.assertNotNull(document); Assert.assertEquals(2, document.getTags().length); }
From source file:io.ingenieux.lambada.invoker.fixtures.Fixture.java
public void doSomethingRawWithContext(InputStream is, OutputStream os, Context c) throws Exception { Integer value = Integer.valueOf(IOUtils.toString(is)); final int result = 2 * value; c.getLogger().log("" + (result * 2)); IOUtils.write("" + result, os); }
From source file:com.epam.wilma.test.server.InputStreamConverter.java
/** * Converts an inputStream to a String with Apache Commons' IOUtils. * @param inputStream InputStream to convert * @return converted stream//from w ww. j ava 2s. co m * @throws IOException when IOUtils fails */ public String getStringFromStream(final InputStream inputStream) throws IOException { return IOUtils.toString(inputStream); }
From source file:gdv.xport.util.HtmlFormatter.java
private static String readTemplate(final String name) throws IOException { InputStream istream = HtmlFormatter.class.getResourceAsStream(name); try {//from w w w . jav a2s .c om return IOUtils.toString(istream); } finally { istream.close(); } }
From source file:com.github.terma.m.server.NodeServlet.java
@Override protected void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { final List<Event> newEvents = GSON.fromJson(IOUtils.toString(request.getInputStream()), EVENTS_TYPE); EventsHolder.get().add(newEvents);//ww w . java2s . c o m NodeManager.INSTANCE.responseFromNode(request.getRemoteHost()); }