Search in sources :

Example 66 with ByteArrayInputStream

use of java.io.ByteArrayInputStream in project cordova-android-chromeview by thedracle.

the class IceCreamCordovaWebViewClient method getWhitelistResponse.

private WebResourceResponse getWhitelistResponse() {
    WebResourceResponse emptyResponse;
    String empty = "";
    ByteArrayInputStream data = new ByteArrayInputStream(empty.getBytes());
    return new WebResourceResponse("text/plain", "UTF-8", data);
}
Also used : WebResourceResponse(android.webkit.WebResourceResponse) ByteArrayInputStream(java.io.ByteArrayInputStream)

Example 67 with ByteArrayInputStream

use of java.io.ByteArrayInputStream in project bazel by bazelbuild.

the class HashInputStreamTest method badChecksum_throwsIOException.

@Test
public void badChecksum_throwsIOException() throws Exception {
    thrown.expect(IOException.class);
    thrown.expectMessage("Checksum");
    assertThat(CharStreams.toString(new InputStreamReader(new HashInputStream(new ByteArrayInputStream("hello".getBytes(UTF_8)), Hashing.sha1(), HashCode.fromString("0000000000000000000000000000000000000000")), UTF_8))).isNull();
}
Also used : InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) Test(org.junit.Test)

Example 68 with ByteArrayInputStream

use of java.io.ByteArrayInputStream in project bigbluebutton by bigbluebutton.

the class IMSPOXRequest method parsePostBody.

public void parsePostBody() {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    try {
        DocumentBuilder db = dbf.newDocumentBuilder();
        postDom = db.parse(new ByteArrayInputStream(postBody.getBytes()));
    } catch (Exception e) {
        errorMessage = "Could not parse XML: " + e.getMessage();
        return;
    }
    try {
        XPath xpath = XPathFactory.newInstance().newXPath();
        XPathExpression expr = xpath.compile("/imsx_POXEnvelopeRequest/imsx_POXBody/*");
        Object result = expr.evaluate(postDom, XPathConstants.NODESET);
        NodeList nodes = (NodeList) result;
        bodyElement = (Element) nodes.item(0);
        operation = bodyElement.getNodeName();
        expr = xpath.compile("/imsx_POXEnvelopeRequest/imsx_POXHeader/*");
        result = expr.evaluate(postDom, XPathConstants.NODESET);
        nodes = (NodeList) result;
        headerElement = (Element) nodes.item(0);
    } catch (Exception e) {
        errorMessage = "Could not parse PATH: " + e.getMessage();
        return;
    }
    if (operation == null || bodyElement == null) {
        errorMessage = "Could not find operation";
        return;
    }
    valid = true;
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ByteArrayInputStream(java.io.ByteArrayInputStream) NodeList(org.w3c.dom.NodeList) IllegalArgumentException(java.lang.IllegalArgumentException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 69 with ByteArrayInputStream

use of java.io.ByteArrayInputStream in project bigbluebutton by bigbluebutton.

the class XMLMap method documentFromString.

// A Utility Method we expose so folks can reuse if they like
public static Document documentFromString(String input) {
    try {
        DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        Document document = parser.parse(new ByteArrayInputStream(input.getBytes()));
        return document;
    } catch (Exception e) {
        return null;
    }
}
Also used : DocumentBuilder(javax.xml.parsers.DocumentBuilder) ByteArrayInputStream(java.io.ByteArrayInputStream) Document(org.w3c.dom.Document)

Example 70 with ByteArrayInputStream

use of java.io.ByteArrayInputStream in project Japid by branaway.

the class JavaSyntaxValidatorTest method testParamList.

@Test
public void testParamList() throws UnsupportedEncodingException, ParseException {
    String src = "class A { void m  (String[ ] a, cc.B f) {m(1 + \"s\", 2);}}";
    ByteArrayInputStream in = new ByteArrayInputStream(src.getBytes("UTF-8"));
    CompilationUnit cu = JavaParser.parse(in, "UTF-8");
    assertNotNull(cu);
    // System.out.println(cu.toString());
    new MethodVisitor().visit(cu, null);
}
Also used : CompilationUnit(japa.parser.ast.CompilationUnit) ByteArrayInputStream(java.io.ByteArrayInputStream) Test(org.junit.Test)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)8004 Test (org.junit.Test)2746 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2096 InputStream (java.io.InputStream)1831 IOException (java.io.IOException)1612 ObjectInputStream (java.io.ObjectInputStream)672 DataInputStream (java.io.DataInputStream)653 X509Certificate (java.security.cert.X509Certificate)412 ObjectOutputStream (java.io.ObjectOutputStream)376 CertificateFactory (java.security.cert.CertificateFactory)369 ArrayList (java.util.ArrayList)354 File (java.io.File)315 HashMap (java.util.HashMap)279 Certificate (java.security.cert.Certificate)239 DataOutputStream (java.io.DataOutputStream)226 InputStreamReader (java.io.InputStreamReader)216 FileInputStream (java.io.FileInputStream)211 Document (org.w3c.dom.Document)186 Test (org.testng.annotations.Test)181 Map (java.util.Map)162