Example usage for android.util Base64 NO_WRAP

List of usage examples for android.util Base64 NO_WRAP

Introduction

In this page you can find the example usage for android.util Base64 NO_WRAP.

Prototype

int NO_WRAP

To view the source code for android.util Base64 NO_WRAP.

Click Source Link

Document

Encoder flag bit to omit all line terminators (i.e., the output will be on one long line).

Usage

From source file:Main.java

public static byte[] base64UrlDecode(String arg) {
    return Base64.decode(arg, Base64.URL_SAFE | Base64.NO_WRAP);
}

From source file:Main.java

public static Bitmap getBitmapByString(String imgSrc) {
    if (imgSrc != null) {
        byte[] buf = Base64.decode(imgSrc, Base64.NO_WRAP);
        ByteArrayInputStream bas = new ByteArrayInputStream(buf);
        Bitmap pic = BitmapFactory.decodeStream(bas);
        return pic;
    } else/*from  www.ja v  a2s  .  c  o m*/
        return null;
}

From source file:Main.java

public static String decodeToFile(File desFile, String encodedString) {
    try {/*from  ww  w  . ja v a2 s.  c o  m*/
        byte[] decodeBytes = Base64.decode(encodedString.getBytes(), Base64.NO_WRAP);
        FileOutputStream fos = new FileOutputStream(desFile);
        fos.write(decodeBytes);
        fos.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

static public String decodeToSgtring(String code) {
    if (code == null || code.length() == 0) {
        return "";
    }// ww  w .  j  av  a2 s.co m
    try {
        return new String(Base64.decode(code.getBytes(), Base64.NO_WRAP));
    } catch (Exception e) {
        e.printStackTrace();
        return code;
    }

}

From source file:Main.java

public static String base64UrlEncode(byte[] arg) {
    return Base64.encodeToString(arg, 0, arg.length, Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING);
}

From source file:Main.java

/**
 * Encodes input string to Base64/*from   w  w  w .  ja  va  2  s . co  m*/
 *
 * @param input Input string
 * @return Base64 string
 */
public static String toBase64(String input) {
    String base64Str = Base64.encodeToString(input.getBytes(), Base64.NO_WRAP);
    return base64Str;
}

From source file:Main.java

public static String decode(String str, int time) {
    System.out.println(str);//from   w  w  w.  j  a  v  a 2  s  .  c  o m
    String result = new String(str);
    for (int i = 0; i < time; i++) {
        System.out.println("i : " + i);
        byte[] decode = Base64.decode(result.getBytes(), Base64.NO_WRAP);

        result = new String(decode);
    }
    return result;
}

From source file:Main.java

/**
 * decode from a base64 to a bitmap//w  w  w .j  av  a 2s .c o  m
 * 
 * @param base64
 * @return
 */
public static Bitmap decodeFromBase64(String base64) {
    byte[] bitmapArray = Base64.decode(base64, Base64.NO_WRAP | Base64.URL_SAFE);
    return BitmapFactory.decodeByteArray(bitmapArray, 0, bitmapArray.length);
}

From source file:Main.java

public static String generateBase64String(String inString) throws UnsupportedEncodingException {
    byte[] byteTransform = inString.getBytes("UTF-8");
    return Base64.encodeToString(byteTransform, Base64.NO_WRAP);
}

From source file:Main.java

/**
 * @param login login name/*  ww  w  . j ava 2  s .  c  o m*/
 * @param pass  password
 * @return  Base64 Auth encoded string
 */
static String getB64Auth(String login, String pass) {
    String source = login + ":" + pass;
    return "Basic " + Base64.encodeToString(source.getBytes(), Base64.URL_SAFE | Base64.NO_WRAP);
}