android EncodingUtils类
Posted ihrthk
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了android EncodingUtils类相关的知识,希望对你有一定的参考价值。
public final classEncodingUtils
extends Objectjava.lang.Object | |
↳ | org.apache.http.util.EncodingUtils |
Class Overview
The home for utility methods that handle various encoding tasks.
Summary
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
static byte[] | getAsciiBytes( String data) Converts the specified string to byte array of ASCII characters. | ||||||||||
static String | getAsciiString(byte[] data) Converts the byte array of ASCII characters to a string. | ||||||||||
static String | getAsciiString(byte[] data, int offset, int length) Converts the byte array of ASCII characters to a string. | ||||||||||
static byte[] | getBytes( String data, String charset) Converts the specified string to a byte array. | ||||||||||
static String | getString(byte[] data, String charset) Converts the byte array of HTTP content characters to a string. | ||||||||||
static String | getString(byte[] data, int offset, int length, String charset) Converts the byte array of HTTP content characters to a string. |
[Expand] Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
|
Public Methods
public static byte[] getAsciiBytes (String data)
Since: API Level 1Converts the specified string to byte array of ASCII characters.
Parameters
data | the string to be encoded |
---|
Returns
- The string as a byte array.
public static String getAsciiString (byte[] data)
Since: API Level 1Converts the byte array of ASCII characters to a string. This method is to be used when decoding content of HTTP elements (such as response headers)
Parameters
data | the byte array to be encoded |
---|
Returns
- The string representation of the byte array
public static String getAsciiString (byte[] data, int offset, int length)
Since: API Level 1Converts the byte array of ASCII characters to a string. This method is to be used when decoding content of HTTP elements (such as response headers)
Parameters
data | the byte array to be encoded |
---|---|
offset | the index of the first byte to encode |
length | the number of bytes to encode |
Returns
- The string representation of the byte array
public static byte[] getBytes (String data, String charset)
Since: API Level 1Converts the specified string to a byte array. If the charset is not supported the default system charset is used.
Parameters
data | the string to be encoded |
---|---|
charset | the desired character encoding |
Returns
- The resulting byte array.
public static String getString (byte[] data, String charset)
Since: API Level 1Converts the byte array of HTTP content characters to a string. If the specified charset is not supported, default system encoding is used.
Parameters
data | the byte array to be encoded |
---|---|
charset | the desired character encoding |
Returns
- The result of the conversion.
public static String getString (byte[] data, int offset, int length, String charset)
Since: API Level 1Converts the byte array of HTTP content characters to a string. If the specified charset is not supported, default system encoding is used.
Parameters
data | the byte array to be encoded |
---|---|
offset | the index of the first byte to encode |
length | the number of bytes to encode |
charset | the desired character encoding |
Returns
- The result of the conversion.
以上是关于android EncodingUtils类的主要内容,如果未能解决你的问题,请参考以下文章
Android 逆向类加载器 ClassLoader ( 加载 Android 组件的类加载器 | 双亲委派机制实例分析 )