org.joe_e.charset
Class ASCII

java.lang.Object
  extended by org.joe_e.charset.ASCII

public final class ASCII
extends Object

ASCII I/O.


Method Summary
static String decode(byte[] buffer)
          Decodes a US-ASCII string.
static String decode(byte[] buffer, int off, int len)
          Decodes a US-ASCII string.
static byte[] encode(String text)
          Encodes a string in US-ASCII.
static Reader input(InputStream in)
          Constructs an ASCII reader.
static Writer output(OutputStream out)
          Constructs an ASCII writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encode

public static byte[] encode(String text)
Encodes a string in US-ASCII.

Parameters:
text - The text to encode.
Returns:
The ASCII bytes.

decode

public static String decode(byte[] buffer)
Decodes a US-ASCII string. Each byte not corresponding to a US-ASCII character decodes to the Unicode replacement character U+FFFD. This method is equivalent to decode(buffer, 0, buffer.length).

Parameters:
buffer - the ASCII-encoded string to decode
Returns:
The corresponding string
Throws:
IndexOutOfBoundsException

decode

public static String decode(byte[] buffer,
                            int off,
                            int len)
Decodes a US-ASCII string. Each byte not corresponding to a US-ASCII character decodes to the Unicode replacement character U+FFFD.

Parameters:
buffer - the ASCII-encoded string to decode
off - where to start decoding
len - how many bytes to decode
Returns:
the corresponding string
Throws:
IndexOutOfBoundsException

input

public static Reader input(InputStream in)
Constructs an ASCII reader.

Parameters:
in - The binary input stream
Returns:
the ASCII character reader.

output

public static Writer output(OutputStream out)
Constructs an ASCII writer.

Parameters:
out - the output stream.