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


Java EncodingUtils.getBytes方法代码示例

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


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

示例1: readDataUri

import org.apache.http.util.EncodingUtils; //导入方法依赖的package包/类
private OpenForReadResult readDataUri(Uri uri) {
    String uriAsString = uri.getSchemeSpecificPart();
    int commaPos = uriAsString.indexOf(',');
    if (commaPos == -1) {
        return null;
    }
    String[] mimeParts = uriAsString.substring(0, commaPos).split(";");
    String contentType = null;
    boolean base64 = false;
    if (mimeParts.length > 0) {
        contentType = mimeParts[0];
    }
    for (int i = 1; i < mimeParts.length; ++i) {
        if ("base64".equalsIgnoreCase(mimeParts[i])) {
            base64 = true;
        }
    }
    String dataPartAsString = uriAsString.substring(commaPos + 1);
    byte[] data = base64 ? Base64.decode(dataPartAsString, Base64.DEFAULT) : EncodingUtils.getBytes(dataPartAsString, "UTF-8");
    InputStream inputStream = new ByteArrayInputStream(data);
    return new OpenForReadResult(uri, inputStream, contentType, data.length, null);
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:23,代码来源:CordovaResourceApi.java

示例2: fixName

import org.apache.http.util.EncodingUtils; //导入方法依赖的package包/类
private final String fixName( ZipEntry entry ) {
        try {
            String entry_name = entry.getName();
            
            if( android.os.Build.VERSION.SDK_INT >= 10 )
                return entry_name; // already fixed?
            
            byte[] ex = entry.getExtra();
            if( ex != null && ex.length == 2 && ex[0] == 1 && ex[1] == 2 ) 
                return entry_name;
            byte bytes[];
/*            
            bytes = EncodingUtils.getAsciiBytes( entry_name );
            bytes = EncodingUtils.getBytes( entry_name, "windows-1250" );
*/            
            bytes = EncodingUtils.getBytes( entry_name, "iso-8859-1" );
            return new String( bytes );
        } catch( Exception e ) {
            e.printStackTrace();
        }
        return null;
    }
 
开发者ID:NullNoname,项目名称:ghostcommander-supath,代码行数:23,代码来源:ZipAdapter.java

示例3: loadUrl

import org.apache.http.util.EncodingUtils; //导入方法依赖的package包/类
/**
 * 加载网页
 */
private void loadUrl() {
    if (requestType.equals(NetWorkType.POST)) {//POST请求
        byte[] base64s = EncodingUtils.getBytes(webPostData, "base64");
        mWebView.postUrl(webUrl, base64s);
    } else {//GET请求
        LogUtils.e("TAG", "loadUrl");
        mWebView.loadUrl(webUrl);
    }
}
 
开发者ID:jianesrq0724,项目名称:UpdateLibrary,代码行数:13,代码来源:X5WebViewBrowseActivity.java

示例4: getContent

import org.apache.http.util.EncodingUtils; //导入方法依赖的package包/类
/**
 * Gets the content in bytes.  Bytes are lazily created to allow the charset to be changed
 * after the part is created.
 * 
 * @return the content in bytes
 */
private byte[] getContent() {
    if (content == null) {
        content = EncodingUtils.getBytes(value, getCharSet());
    }
    return content;
}
 
开发者ID:erickok,项目名称:transdroid,代码行数:13,代码来源:StringPart.java

示例5: getContent

import org.apache.http.util.EncodingUtils; //导入方法依赖的package包/类
/**
 * Gets the content in bytes.  Bytes are lazily created to allow the charset to be changed
 * after the part is created.
 * 
 * @return the content in bytes
 */
private byte[] getContent() {
    if (content == null) {
        content = EncodingUtils.getBytes(value, "utf-8");
    }
    return content;
}
 
开发者ID:erickok,项目名称:transdroid,代码行数:13,代码来源:Utf8StringPart.java

示例6: getContent

import org.apache.http.util.EncodingUtils; //导入方法依赖的package包/类
/**
 * Gets the content in bytes.  Bytes are lazily created to allow the charset to be changed
 * after the part is created.
 *
 * @return the content in bytes
 */
private byte[] getContent() {
    if (this.content == null) {
        this.content = EncodingUtils.getBytes(this.value, getCharSet());
    }
    return this.content;
}
 
开发者ID:haku,项目名称:Onosendai,代码行数:13,代码来源:StringPart.java

示例7: HttpResponse

import org.apache.http.util.EncodingUtils; //导入方法依赖的package包/类
public HttpResponse(final int status, final String reason, final String content, final ContentType type) {
	this(status, reason, EncodingUtils.getBytes(content, type.getCharset().toString()), type);
}
 
开发者ID:LAW-Unimi,项目名称:BUbiNG,代码行数:4,代码来源:StringHttpMessages.java

示例8: UTF8

import org.apache.http.util.EncodingUtils; //导入方法依赖的package包/类
public static String UTF8 (String s)
{
    byte bytes[]=EncodingUtils.getBytes(s,"UTF-8");
    return new String(bytes);
}
 
开发者ID:FutureSonic,项目名称:FutureSonic-Server,代码行数:6,代码来源:DownloadController.java

示例9: cp866

import org.apache.http.util.EncodingUtils; //导入方法依赖的package包/类
public static String cp866 (String s)
{
    byte bytes[]=EncodingUtils.getBytes(s,"cp866");
    return new String(bytes);
}
 
开发者ID:FutureSonic,项目名称:FutureSonic-Server,代码行数:6,代码来源:DownloadController.java

示例10: iso

import org.apache.http.util.EncodingUtils; //导入方法依赖的package包/类
public static String iso (String s)
{
    byte bytes[]=EncodingUtils.getBytes(s,"ISO-8859-1");
    return new String(bytes);
}
 
开发者ID:FutureSonic,项目名称:FutureSonic-Server,代码行数:6,代码来源:DownloadController.java


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