List of usage examples for java.io ByteArrayInputStream ByteArrayInputStream
public ByteArrayInputStream(byte buf[])
From source file:com.mirth.connect.server.userutil.HTTPUtil.java
/** * Converts a block of HTTP header fields into a Map containing each header key and value. * //from www . j a va 2s . c om * @param str * The block of HTTP header fields to convert. * @return The converted Map containing header key-value pairs. * @throws Exception */ public static Map<String, String> parseHeaders(String str) throws Exception { Map<String, String> headersMap = new HashMap<String, String>(); Header[] headers = HttpParser.parseHeaders(new ByteArrayInputStream(str.getBytes()), "UTF-8"); for (int i = 0; i < headers.length; i++) { headersMap.put(headers[i].getName(), headers[i].getValue()); } return headersMap; }
From source file:ByteUtils.java
public static byte[] unpackRaw(byte[] b) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayInputStream bais = new ByteArrayInputStream(b); GZIPInputStream zis = new GZIPInputStream(bais); byte[] tmpBuffer = new byte[256]; int n;//ww w .j a v a 2 s .c o m while ((n = zis.read(tmpBuffer)) >= 0) baos.write(tmpBuffer, 0, n); zis.close(); return baos.toByteArray(); }
From source file:net.mentalarray.doozie.PigSupport.PigInBlanket.java
private static BufferedReader stringToBufferedReader(String input) { return new BufferedReader( new InputStreamReader(new ByteArrayInputStream(input.getBytes(StandardCharsets.UTF_8)))); }
From source file:Main.java
public static boolean isDebuggable(Context ctx) { boolean debuggable = false; try {/*from ww w .j ava 2 s .c o m*/ PackageInfo pinfo = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), PackageManager.GET_SIGNATURES); Signature signatures[] = pinfo.signatures; for (int i = 0; i < signatures.length; i++) { CertificateFactory cf = CertificateFactory.getInstance("X.509"); ByteArrayInputStream stream = new ByteArrayInputStream(signatures[i].toByteArray()); X509Certificate cert = (X509Certificate) cf.generateCertificate(stream); debuggable = cert.getSubjectX500Principal().equals(DEBUG_DN); if (debuggable) break; } } catch (NameNotFoundException e) { } catch (CertificateException e) { } return debuggable; }