List of usage examples for java.io ByteArrayInputStream ByteArrayInputStream
public ByteArrayInputStream(byte buf[])
From source file:Main.java
public static void writeBytes(File destination, byte[] data) throws IOException { saveToFile(new ByteArrayInputStream(data), destination); }
From source file:Main.java
public static InputStream Bitmap2InputStream(Bitmap bm) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.PNG, 100, baos); InputStream is = new ByteArrayInputStream(baos.toByteArray()); return is;//from w w w . ja va 2 s .c o m }
From source file:Main.java
public static InputStream Bitmap2InputStream(Bitmap bm) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.JPEG, 100, baos); InputStream is = new ByteArrayInputStream(baos.toByteArray()); return is;/*w ww .ja va2 s. c om*/ }
From source file:Main.java
public static Object stringToObject(String encodedObject) { try {/*www . java2s .c o m*/ return new ObjectInputStream( new Base64InputStream(new ByteArrayInputStream(encodedObject.getBytes()), Base64.DEFAULT)) .readObject(); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static boolean validateXml(String xml) { boolean flag = true; if (xml == null) { flag = false;//from w w w .j a v a 2s.com } else { InputStream is = new ByteArrayInputStream(xml.getBytes()); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try { DocumentBuilder builder = dbf.newDocumentBuilder(); builder.parse(is); } catch (Exception e) { flag = false; } } return flag; }
From source file:Main.java
public static Object deSerialization(String str) throws IOException, ClassNotFoundException { byte[] mobileBytes = Base64.decode(str.getBytes(), Base64.DEFAULT); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(mobileBytes); ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream); Object object = (Object) objectInputStream.readObject(); objectInputStream.close();/*from w w w.ja va2s . c o m*/ return object; }
From source file:Main.java
public static Element toRootElement(String content) { InputStream input = new ByteArrayInputStream(content.getBytes()); Element root = read(input).getDocumentElement(); return root;//w w w . j a v a2 s.com }
From source file:Main.java
public static InputStream getInputStreamValue(Bitmap bitmap) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); InputStream in = new ByteArrayInputStream(stream.toByteArray()); return in;//from w w w . j a v a 2 s . c om }
From source file:Main.java
public static byte[] gunzip(byte[] data) throws IOException { InputStream in = new GZIPInputStream(new ByteArrayInputStream(data)); ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteStreams.copy(in, out);//from w ww. j ava 2s . co m return out.toByteArray(); }
From source file:Main.java
public static Document parseXml(String xml) throws Exception { return newDocumentBuilder().parse(new ByteArrayInputStream(xml.getBytes("UTF-8"))); }