List of usage examples for android.util Base64 DEFAULT
int DEFAULT
To view the source code for android.util Base64 DEFAULT.
Click Source Link
From source file:Main.java
public static Bitmap base64StringToBitmap(String str) { if (str == null) { return null; }//from w w w. j a va 2 s . c o m byte[] bytes; bytes = Base64.decode(str, Base64.DEFAULT); return BitmapFactory.decodeByteArray(bytes, 0, bytes.length); }
From source file:Main.java
public static String encodeToString(Bitmap bitmap) { if (bitmap == null) { return ""; }// www.jav a2 s.co m return Base64.encodeToString(encodeToBytes(bitmap), Base64.DEFAULT); }
From source file:Main.java
public static Bitmap getImage(String body) { int index = TAG_IMAGE.length(); body = body.substring(index);/*from w ww . j a v a 2s . c om*/ byte[] imageData = Base64.decode(body, Base64.DEFAULT); return BitmapFactory.decodeByteArray(imageData, 0, imageData.length); }
From source file:Main.java
public static String encode(String plain, Charset charset) { return Base64.encodeToString(plain.getBytes(charset), Base64.DEFAULT); }
From source file:Main.java
public static String encoded(String data) throws UnsupportedEncodingException { // byte[] b = Base64.encodeBase64(data.getBytes(ENCODING)); byte[] b = Base64.encode(data.getBytes(ENCODING), Base64.DEFAULT); return new String(b, ENCODING); }
From source file:Main.java
public static List String2SceneList(String SceneListString) throws IOException, ClassNotFoundException { byte[] mobileBytes = Base64.decode(SceneListString.getBytes(), Base64.DEFAULT); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(mobileBytes); ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream); List SceneList = (List) objectInputStream.readObject(); objectInputStream.close();/*from ww w . j av a 2s. co m*/ return SceneList; }
From source file:Main.java
/** * Decodes the base64 string into byte array * //from w w w .j a v a2s .c o m * @param imageDataString * - a {@link java.lang.String} * @return byte array */ private static byte[] decodeFile(String imageDataString) throws IllegalArgumentException { return Base64.decode(imageDataString, Base64.DEFAULT); }
From source file:Main.java
public static String convertBitmapToBase64(Bitmap bitmap) { final int size = bitmap.getByteCount(); ByteBuffer dst = ByteBuffer.allocate(size); bitmap.copyPixelsToBuffer(dst);/* ww w .jav a 2 s. c om*/ return Base64.encodeToString(dst.array(), Base64.DEFAULT); }
From source file:Main.java
public static Object toObject(String base64str) { Object obj = null;//from ww w .ja v a 2 s. com try { obj = toObject(Base64.decode(base64str, Base64.DEFAULT)); } catch (Exception e) { e.printStackTrace(); } return obj; }
From source file:Main.java
public static String bytesToBinary(File file) { String fileStr = ""; try {/*from www . j av a2 s. co m*/ byte[] bts = getFileBytes(file); fileStr = Base64.encodeToString(bts, Base64.DEFAULT); } catch (Exception e) { // TODO: handle exception } return fileStr; }