當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。