本文整理汇总了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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}