Example usage for java.io ByteArrayOutputStream toString

List of usage examples for java.io ByteArrayOutputStream toString

Introduction

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

Prototype

public synchronized String toString() 

Source Link

Document

Converts the buffer's contents into a string decoding bytes using the platform's default character set.

Usage

From source file:fr.aliasource.webmail.server.proxy.client.http.folder.DeleteFolderMethod.java

public void deleteFolder(Folder f) {
    Map<String, String> params = new HashMap<String, String>();
    params.put("token", token);
    params.put("folder", f.getName());

    Document doc = null;/* w w  w .  j ava 2 s. c  o  m*/
    try {
        doc = getFolderAsXML(f);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        DOMUtils.serialise(doc, out);
        params.put("xmlfolder", out.toString());
        executeVoid(params);

        if (logger.isInfoEnabled()) {
            logger.info("folder deleted !");
        }

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}

From source file:fr.aliasource.webmail.server.proxy.client.http.folder.RenameFolderMethod.java

public void rename(Folder f, String newName) {
    Map<String, String> params = new HashMap<String, String>();
    params.put("token", token);
    params.put("folder", f.getName());
    params.put("newName", newName);
    Document doc = null;//from   w  w  w . j a  va 2  s  .  c o m
    try {
        doc = getFolderAsXML(f);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        DOMUtils.serialise(doc, out);
        params.put("xmlfolder", out.toString());
        executeVoid(params);

        if (logger.isInfoEnabled()) {
            logger.info("folder renamed !");
        }

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}

From source file:io.milton.httpclient.ReportMethod.java

public Document getResponseAsDocument(HttpClient client, HttpContext context) throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Utils.executeHttpWithStatus(client, this, out, context);
    String xml = out.toString();
    try {/*w w w. jav  a  2  s . c o  m*/
        Document document = Host.getJDomDocument(new ByteArrayInputStream(xml.getBytes("UTF-8")));
        return document;
    } catch (JDOMException ex) {
        throw new RuntimeException(xml, ex);
    }
}

From source file:net.bpelunit.framework.model.test.wire.IncomingMessage.java

public String getMessageAsString() {
    if (message == null) {
        return null;
    }//from   w w  w.j a v a 2  s.co m

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        message.writeTo(out);
        return out.toString(); // TODO Character set
    } catch (SOAPException e) {
        return null;
    } catch (IOException e) {
        return null;
    }
}

From source file:eltharis.wsn.showIDActivity.java

private String executeGET(int id) throws Exception {
    HttpClient httpclient = new DefaultHttpClient(); //tutaj jest podobnie jak w showAllActivity
    HttpResponse response = httpclient/*from  www  .  ja v a  2s  .  c  o m*/
            .execute(new HttpGet("https://agile-depths-5530.herokuapp.com/usershow/" + Integer.toString(id)));
    StatusLine statusline = response.getStatusLine();
    Toast toast = Toast.makeText(getApplicationContext(),
            "HTTP Response: " + Integer.toString(statusline.getStatusCode()), Toast.LENGTH_LONG);
    toast.show();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    response.getEntity().writeTo(out);
    String responseString = out.toString();
    out.close();
    return responseString;
}

From source file:fr.aliasource.webmail.server.proxy.client.http.StoreHistoryMethod.java

public void store(History history) {
    Map<String, String> params = new HashMap<String, String>();
    params.put("token", token);

    Document doc = null;/*from w  w  w  .j  a v a  2s. c  om*/
    try {
        doc = asXml(history);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        DOMUtils.serialise(doc, out);
        params.put("history", out.toString());

        executeVoid(params);
    } catch (Exception e) {
        logger.error("Error saving history", e);
    }
}

From source file:com.wavemaker.runtime.ws.jaxws.SOAPLoggingHandler.java

private void log(SOAPMessageContext context) {
    Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    String messageText;/*from w w w . j  av a 2 s  .  c o  m*/
    if (outboundProperty.booleanValue()) {
        messageText = "Outbound SOAP message:\n";
    } else {
        messageText = "Inbound SOAP message:\n";
    }

    SOAPMessage message = context.getMessage();
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        message.writeTo(baos);
        log.debug(messageText + baos.toString());
        baos.close();
    } catch (Exception e) {
        log.error(e);
    }
}

From source file:org.energyos.espi.common.domain.ServiceCategoryMarshallerTests.java

private String newXML() throws DatatypeConfigurationException {
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    atomMarshaller.marshal(EspiFactory.newServiceCategory(), new StreamResult(os));
    return os.toString();
}

From source file:org.raml.parser.tagresolver.JacksonTagResolver.java

@Override
public Node resolve(Node node, ResourceLoader resourceLoader, NodeHandler nodeHandler) {
    String className = ((ScalarNode) node).getValue();
    try {/*w  w w  .j a v  a 2 s  .c o m*/
        Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
        ObjectMapper objectMapper = new ObjectMapper();
        SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
        objectMapper.acceptJsonFormatVisitor(objectMapper.constructType(clazz), visitor);
        JsonSchema jsonSchema = visitor.finalSchema();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        objectMapper.writeValue(baos, jsonSchema);
        String schema = baos.toString();
        return new ScalarNode(Tag.STR, schema, node.getStartMark(), node.getEndMark(),
                ((ScalarNode) node).getStyle());
    } catch (Exception e) {
        throw new YAMLException(e);
    }
}

From source file:com.adaptris.util.ByteArrayDataSourceTest.java

public void testInputStream() throws Exception {
    ByteArrayDataSource bads = new ByteArrayDataSource(EXAMPLE_XML.getBytes(), "text/xml", "name");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    out.write(bads.getBytes());//  ww  w  .  ja v a 2s .  c om
    out.flush();
    assertEquals("XML", out.toString(), EXAMPLE_XML);
}