android EncodingUtils类

来源:互联网 发布:行书名家有哪些知乎 编辑:程序博客网 时间:2024/06/05 12:06
public final class

EncodingUtils

extends Object
java.lang.Object   ↳org.apache.http.util.EncodingUtils

Class Overview

The home for utility methods that handle various encoding tasks.

Summary

Public Methodsstatic 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
Objectclone()
Creates and returns a copy of this Object.
booleanequals(Object o)
Compares this instance with the specified object and indicates if they are equal.
voidfinalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
final Class<?>getClass()
Returns the unique instance of Class that represents this object's class.
inthashCode()
Returns an integer hash code for this object.
final voidnotify()
Causes a thread which is waiting on this object's monitor (by means of calling one of thewait() methods) to be woken up.
final voidnotifyAll()
Causes all threads which are waiting on this object's monitor (by means of calling one of thewait() methods) to be woken up.
StringtoString()
Returns a string containing a concise, human-readable description of this object.
final voidwait()
Causes the calling thread to wait until another thread calls thenotify() or notifyAll() method of this object.
final voidwait(long millis, int nanos)
Causes the calling thread to wait until another thread calls thenotify() or notifyAll() method of this object or until the specified timeout expires.
final voidwait(long millis)
Causes the calling thread to wait until another thread calls thenotify() or notifyAll() method of this object or until the specified timeout expires.

Public Methods

public static byte[]getAsciiBytes (String data)

Since: API Level 1

Converts the specified string to byte array of ASCII characters.

Parameters
data the string to be encoded
Returns
  • The string as a byte array.

public staticStringgetAsciiString (byte[] data)

Since: API Level 1

Converts 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 staticStringgetAsciiString (byte[] data, int offset, int length)

Since: API Level 1

Converts 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 encodedoffset the index of the first byte to encodelength 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 1

Converts 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 encodedcharset the desired character encoding
Returns
  • The resulting byte array.

public staticStringgetString (byte[] data, String charset)

Since: API Level 1

Converts 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 encodedcharset the desired character encoding
Returns
  • The result of the conversion.

public staticStringgetString (byte[] data, int offset, int length,String charset)

Since: API Level 1

Converts 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 encodedoffset the index of the first byte to encodelength the number of bytes to encodecharset the desired character encoding
Returns
  • The result of the conversion. 
原创粉丝点击