org.at4j.support.nio.charset
Class Charsets

java.lang.Object
  extended by org.at4j.support.nio.charset.Charsets

public final class Charsets
extends Object

This class contains Charset constants for commonly used charsets and utility methods for converting between byte and character data.

Since:
1.0
Author:
Karl Gustafsson

Field Summary
static Charset ASCII
          The US-ASCII charset.
static Charset UTF16
          The UTF-16 charset.
static Charset UTF8
          The UTF-8 charset.
 
Method Summary
static byte[] getBytes(String text, Charset cs)
          Convert the given text to byte data using the supplied charset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UTF8

public static final Charset UTF8
The UTF-8 charset.


UTF16

public static final Charset UTF16
The UTF-16 charset.


ASCII

public static final Charset ASCII
The US-ASCII charset.

Method Detail

getBytes

public static byte[] getBytes(String text,
                              Charset cs)
                       throws At4JException
Convert the given text to byte data using the supplied charset.

Parameters:
text - The text to convert.
cs - The charset to use for converting the text.
Returns:
Byte data.
Throws:
At4JException - On character coding errors. See CharacterCodingException.