Package org.apache.http.util
Class EncodingUtils
- java.lang.Object
-
- org.apache.http.util.EncodingUtils
-
public final class EncodingUtils extends java.lang.ObjectThe home for utility methods that handle various encoding tasks.- Since:
- 4.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]getAsciiBytes(java.lang.String data)Converts the specified string to byte array of ASCII characters.static java.lang.StringgetAsciiString(byte[] data)Converts the byte array of ASCII characters to a string.static java.lang.StringgetAsciiString(byte[] data, int offset, int length)Converts the byte array of ASCII characters to a string.static byte[]getBytes(java.lang.String data, java.lang.String charset)Converts the specified string to a byte array.static java.lang.StringgetString(byte[] data, int offset, int length, java.lang.String charset)Converts the byte array of HTTP content characters to a string.static java.lang.StringgetString(byte[] data, java.lang.String charset)Converts the byte array of HTTP content characters to a string.
-
-
-
Method Detail
-
getString
public static java.lang.String getString(byte[] data, int offset, int length, java.lang.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- 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.
-
getString
public static java.lang.String getString(byte[] data, java.lang.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- the byte array to be encodedcharset- the desired character encoding- Returns:
- The result of the conversion.
-
getBytes
public static byte[] getBytes(java.lang.String data, java.lang.String charset)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.
-
getAsciiBytes
public static byte[] getAsciiBytes(java.lang.String data)
Converts the specified string to byte array of ASCII characters.- Parameters:
data- the string to be encoded- Returns:
- The string as a byte array.
-
getAsciiString
public static java.lang.String getAsciiString(byte[] data, int offset, 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- 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
-
getAsciiString
public static java.lang.String getAsciiString(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- the byte array to be encoded- Returns:
- The string representation of the byte array
-
-