Example usage for java.io OutputStream toString

List of usage examples for java.io OutputStream toString

Introduction

In this page you can find the example usage for java.io OutputStream toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:hu.petabyte.redflags.web.svc.NoticesSvc.java

private String sql(List<Filter> filters, boolean counting, boolean orderByFlags)
        throws TemplateException, IOException {
    Map<String, Object> root = new HashMap<String, Object>();
    root.put("filters", filters);
    if (counting) {
        root.put("counting", true);
    }// w w w.  j ava  2s  .  com
    if (orderByFlags) {
        root.put("orderByFlags", true);
    }
    OutputStream os = new ByteArrayOutputStream();
    Writer out = new OutputStreamWriter(os);
    tpl.process(root, out);
    out.close();
    StringBuilder sb = new StringBuilder();
    for (String line : os.toString().split("\n")) {
        line = line.replaceAll("\\s+$", "");
        if (!line.isEmpty()) {
            sb.append(line);
            sb.append("\n");
        }
    }
    return sb.toString();
}

From source file:org.fao.geonet.guiservices.versioning.Get.java

private String getTitle(final OutputStream out) throws JDOMException, IOException {
    final String xml = out.toString();
    final byte[] xmlBytes = xml.getBytes(Charset.forName("UTF-8"));
    InputStream is = new ByteArrayInputStream(xmlBytes);
    InputStreamReader isr = new InputStreamReader(is, "UTF-8");
    SAXBuilder sb = new SAXBuilder();
    Document doc;//from w w w  .  ja v  a 2 s . c  om
    doc = sb.build(isr);
    Element element = doc.getRootElement();
    XPath xpath = XPath
            .newInstance("gmd:identificationInfo/*/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString");
    return xpath.valueOf(element);
}

From source file:com.coupa.api.impl.DefaultRepository.java

public List<T> findAll(T prototype, boolean exactMatch) {
    OutputStream outputStream = new ByteArrayOutputStream();
    JAXB.marshal(prototype, outputStream);
    Map<String, String> conditions = XMLToHashMapAdapter.convertToMap(outputStream.toString());
    return findAll(conditions, exactMatch, 0, null);
}

From source file:org.wso2.carbon.identity.entitlement.pip.CarbonAttributeFinder.java

/**
 * Converts DOM object to String. This is a helper method for creating cache key
 *
 * @param evaluationCtx EvaluationCtx//from w w  w . j  av a2  s . com
 * @return String Object
 * @throws TransformerException Exception throws if fails
 */
private String encodeContext(EvaluationCtx evaluationCtx) throws TransformerException {
    OutputStream stream = new ByteArrayOutputStream();
    evaluationCtx.getRequestCtx().encode(stream);
    return stream.toString();
}

From source file:org.saiku.reporting.backend.rest.CdaResource.java

@GET
@Produces({ "application/json" })
@Path("/doQuery")
public String doQuery(@QueryParam("solution") String solution, @QueryParam("path") String path,
        @QueryParam("file") String file, @QueryParam("dataAccessId") String dataAccessId,
        @QueryParam("outputType") String outputType) {

    final OutputStream out = new ByteArrayOutputStream();

    Map<String, Object> params = new HashMap<String, Object>();
    params.put("outputType", outputType);
    params.put("path", path + "/" + file);
    params.put("solution", "");
    params.put("dataAccessId", dataAccessId);

    return out.toString();

}

From source file:slash.navigation.converter.gui.services.CrossingWays.java

public void upload(String username, String password, String url, String name, String description)
        throws IOException {
    OutputStream baos = UploadHelper.parseUrlToGpx(url);
    Post post = new Post("http://www.crossingways.com/services/LiveTracking.asmx/UploadGPX");
    String body = "username=" + username + "&password=" + new String(DigestUtils.sha(password)) + "&trackname="
            + name + "&gpx=" + baos.toString();
    post.setBody(body);//w  w  w  .jav a2s .c  o  m
    String resultBody = post.execute();
    log.info("ResultBody: " + resultBody);
    String result = extractResult(resultBody);
    log.info("Result: " + result);
    if (!"Track saved! Have a nice Day!".equals(result))
        throw new IOException("Cannot upload url: " + result);
}

From source file:ambit.data.qmrf.QMRFAttachment.java

public Object retrieveContent() throws Exception {
    System.out.println("retrieveContent");
    if (content != null)
        return content;

    InputStream in = getContentAsStream();
    byte[] bytes = new byte[512];
    int len;//  ww  w .j av a 2  s  .com
    OutputStream out = new ByteArrayOutputStream();
    writeContent(in, out);
    in.close();
    String c = out.toString();
    out.close();
    return c;

}

From source file:de.escidoc.bwelabs.deposit.DepositServiceSpec.java

private HttpResponse saveConfiguration(OutputStream os)
        throws URISyntaxException, IOException, ClientProtocolException {
    LOG.debug("Configuration as String: " + os.toString());
    HttpClient client = new DefaultHttpClient();

    HttpPut put = new HttpPut(new URI(CONFIGURATION_DEPOSIT_URI));
    put.setEntity(new StringEntity(os.toString()));
    HttpResponse response = client.execute(put);
    return response;
}

From source file:org.apache.wiki.util.CryptoUtilTest.java

public void testCommandLineVerify() throws Exception {
    // Save old printstream
    PrintStream oldOut = System.out;

    // Swallow System out and get command output
    OutputStream out = new ByteArrayOutputStream();
    System.setOut(new PrintStream(out));
    CryptoUtil.main(new String[] { "--verify", "testing123", "{SSHA}yfT8SRT/WoOuNuA6KbJeF10OznZmb28=" });
    String output = new String(out.toString());

    // Restore old printstream
    System.setOut(oldOut);//from   ww  w.  j a v a 2 s.  co  m

    // Run our tests
    assertTrue(output.startsWith("true"));
}

From source file:org.romaframework.aspect.view.html.HtmlServlet.java

protected void renderResponse(final HttpServletRequest request, final HttpServletResponse response)
        throws IOException {
    setResponseHeaders(response);//from www .j av a 2  s  .co m
    final String pageId = HtmlViewAspectHelper.newPageId();
    request.setAttribute(PAGE_ID_PARAM, pageId);
    request.getSession().setAttribute(PAGE_ID_PARAM, pageId);

    final HtmlViewScreen screen = (HtmlViewScreen) Roma.aspect(ViewAspect.class).getScreen();

    synchronized (screen) {
        OutputStream out = new ByteArrayOutputStream();
        Writer w = new OutputStreamWriter(out);
        screen.render(request, true, true, w);
        w.flush();
        String buff = out.toString();
        buff = flushBuffers(buff);
        response.getWriter().append(buff);
        ((HtmlViewAspect) Roma.view()).cleanDirtyComponents();
    }
}