当前位置: 首页>>代码示例>>Java>>正文


Java Base64.DEFAULT属性代码示例

本文整理汇总了Java中android.util.Base64.DEFAULT属性的典型用法代码示例。如果您正苦于以下问题:Java Base64.DEFAULT属性的具体用法?Java Base64.DEFAULT怎么用?Java Base64.DEFAULT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.util.Base64的用法示例。


在下文中一共展示了Base64.DEFAULT属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: privateBase64Decoder

/**
 * Private decoder in base64
 *
 * @param toDecode String to be encoded
 * @param flags flags to decode the String
 * @return decoded String in base64
 */
private static String privateBase64Decoder(String toDecode, int flags) {
    if (flags == -1) {
        flags = Base64.DEFAULT;
    }

    byte[] data1 = Base64.decode(toDecode, flags);
    String decodedBase64 = null;
    try {
        decodedBase64 = new String(data1, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }

    return decodedBase64;
}
 
开发者ID:yongbeam,项目名称:AirQuickUtils,代码行数:22,代码来源:AirSecurity.java

示例2: getPathFromUri

/**
 * Get an input stream based on file path or uri content://, http://, file://
 *
 * @param path path to file
 * @return an input stream
 * @throws IOException
 */
private InputStream getPathFromUri(String path) throws IOException {
    if (path.startsWith("data:")) { // data:image/png;base64,[ENCODED_IMAGE]
        String dataInfos = path.substring(0, path.indexOf(','));
        dataInfos = dataInfos.substring(dataInfos.indexOf(':') + 1);
        String baseEncoding = dataInfos.substring(dataInfos.indexOf(';') + 1);
        // [ENCODED_IMAGE]
        if("base64".equalsIgnoreCase(baseEncoding)) {
            String img = path.substring(path.indexOf(',') + 1); 
            byte[] encodedData = img.getBytes();
            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(encodedData, 0, encodedData.length);
            Base64InputStream base64InputStream = new Base64InputStream(byteArrayInputStream, Base64.DEFAULT);
            return base64InputStream;
        } else {
            LOG.d(LOG_TAG, "Could not decode image. The found base encoding is " + baseEncoding);
        }
    }  
    if (path.startsWith("content:")) {
        Uri uri = Uri.parse(path);
        return mApp.getActivity().getContentResolver().openInputStream(uri);
    }

    if (path.startsWith(ASSET_URL_PREFIX)) {
        String assetRelativePath = path.replace(ASSET_URL_PREFIX, "");
        return mApp.getActivity().getAssets().open(assetRelativePath);
    }

    if (path.startsWith("http:") || path.startsWith("https:") || path.startsWith("file:")) {
        URL url = new URL(path);
        return url.openStream();
    }

    return new FileInputStream(path);
}
 
开发者ID:rodrigonsh,项目名称:alerta-fraude,代码行数:40,代码来源:ContactAccessorSdk5.java

示例3: privateBase64Encoder

/**
 * private Encoder in base64
 *
 * @param toEncode String to be encoded
 * @param flags flags to encode the String
 * @return encoded String in base64
 */
private static String privateBase64Encoder(String toEncode, int flags) {
    byte[] data = null;
    try {
        data = toEncode.getBytes("UTF-8");
    } catch (UnsupportedEncodingException e1) {
        e1.printStackTrace();
    }

    if (flags == -1) {
        flags = Base64.DEFAULT;
    }

    return Base64.encodeToString(data, flags);
}
 
开发者ID:yongbeam,项目名称:AirQuickUtils,代码行数:21,代码来源:AirSecurity.java


注:本文中的android.util.Base64.DEFAULT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。