Top Description Constructors Methods
org.apache.http.util

public final Class EncodingUtils

extends Object
Class Inheritance
Imports
java.io.UnsupportedEncodingException, org.apache.http.Consts

The home for utility methods that handle various encoding tasks.
Since
4.0

Constructor Summary

AccessConstructor and Description
private
EncodingUtils()

This class should not be instantiated.

Method Summary

Modifier and TypeMethod and Description
public static byte[]

Returns:

The string as a byte array.
getAsciiBytes
(final String
the string to be encoded
data
)

Converts the specified string to byte array of ASCII characters.

public static String

Returns:

The string representation of the byte array
getAsciiString
(final byte[]
the byte array to be encoded
data
,
final int
the index of the first byte to encode
offset
,
final int
the number of bytes to encode
length
)

Converts the byte array of ASCII characters to a string.

public static String

Returns:

The string representation of the byte array
getAsciiString
(final byte[]
the byte array to be encoded
data
)

Converts the byte array of ASCII characters to a string.

public static byte[]

Returns:

The resulting byte array.
getBytes
(final String
the string to be encoded
data
,
final String
the desired character encoding
charset
)

Converts the specified string to a byte array.

public static String

Returns:

The result of the conversion.
getString
(final byte[]
the byte array to be encoded
data
,
final int
the index of the first byte to encode
offset
,
final int
the number of bytes to encode
length
,
final String
the desired character encoding
charset
)

Converts the byte array of HTTP content characters to a string.

public static String

Returns:

The result of the conversion.
getString
(final byte[]
the byte array to be encoded
data
,
final String
the desired character encoding
charset
)

Converts the byte array of HTTP content characters to a string.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

EncodingUtilsback to summary
private EncodingUtils()

This class should not be instantiated.

Method Detail

getAsciiBytesback to summary
public static byte[] getAsciiBytes(final String data)

Converts the specified string to byte array of ASCII characters.

Parameters
data:String

the string to be encoded

Returns:byte[]

The string as a byte array.

getAsciiStringback to summary
public static String getAsciiString(final byte[] data, final int offset, final int length)

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:byte[]

the byte array to be encoded

offset:int

the index of the first byte to encode

length:int

the number of bytes to encode

Returns:String

The string representation of the byte array

getAsciiStringback to summary
public static String getAsciiString(final byte[] data)

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:byte[]

the byte array to be encoded

Returns:String

The string representation of the byte array

getBytesback to summary
public static byte[] getBytes(final String data, final String charset)

Converts the specified string to a byte array. If the charset is not supported the default system charset is used.

Parameters
data:String

the string to be encoded

charset:String

the desired character encoding

Returns:byte[]

The resulting byte array.

getStringback to summary
public static String getString(final byte[] data, final int offset, final int length, final String charset)

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:byte[]

the byte array to be encoded

offset:int

the index of the first byte to encode

length:int

the number of bytes to encode

charset:String

the desired character encoding

Returns:String

The result of the conversion.

getStringback to summary
public static String getString(final byte[] data, final String charset)

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:byte[]

the byte array to be encoded

charset:String

the desired character encoding

Returns:String

The result of the conversion.