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);
}
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();
}
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;
}
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;
}
}
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);
}
Aggregations