Example usage for java.io ByteArrayInputStream toString

List of usage examples for java.io ByteArrayInputStream toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:jlib.xml.XMLUtil.java

public static Document loadXML(ByteArrayInputStream byteArrayInputStream) {
    try {/*from w w w  . jav a2 s .  c om*/
        StreamSource streamSource = new StreamSource(byteArrayInputStream);
        DocumentBuilderFactory dbf = DocumentBuilderFactoryImpl.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document doc = db.newDocument();
        Result res = new DOMResult(doc);
        TransformerFactory tr = TransformerFactory.newInstance();
        Transformer xformer = tr.newTransformer();
        xformer.transform(streamSource, res);

        return doc;
    } catch (Exception e) {
        String csError = e.toString();
        Log.logImportant(csError);
        Log.logImportant(
                "ERROR while loading XML from byteArrayInputStream " + byteArrayInputStream.toString());
    }
    return null;
}

From source file:com.microsoft.azure.iot.service.sdk.Message.java

/**
* stream: a stream containing the body of the message
 * @param stream The stream containing the message body
**///  ww  w.j a v a2  s .  c  o m
public Message(ByteArrayInputStream stream) {
    if (stream != null) {
        this.body = stream.toString().getBytes();
    }
}

From source file:com.microsoft.azure.sdk.iot.service.sdk.Message.java

/**
* stream: a stream containing the body of the message
 * @param stream The stream containing the message body
**//*from  w w w .ja  v a 2  s . com*/
public Message(ByteArrayInputStream stream) {
    this();
    if (stream != null) {
        this.body = stream.toString().getBytes();
    }
}