THE Java™ Programming Language, Fourth Edition

(Jeff_L) #1
Constructs a new String by converting the bytes, from index start up to
a maximum of count bytes, into characters using the default encoding for
the default locale.

publicString(byte[] bytes)

Equivalent to String(bytes, 0, bytes.length).

publicString(byte[] bytes, int start, int count, String enc)
throws UnsupportedEncodingException

Constructs a new String by converting the bytes, from index start up to
a maximum of count bytes, into characters using the encoding named by
enc.

publicString(byte[] bytes, String enc)throws
UnsupportedEncodingException

Equivalent to String(bytes,0,bytes.length,enc).

public byte[]getBytes()

Returns a byte array that encodes the contents of the string using the default
encoding for the default locale.

public byte[]getBytes(String enc)throws
UnsupportedEncodingException

Returns a byte array that encodes the contents of the string using the
encoding named by enc.

The String constructors for building from byte arrays make copies of the data, so further modifications to
the arrays will not affect the contents of the String.


13.2.8. Character Set Encoding


A character set encoding specifies how to convert between raw 8-bit "characters" and their 16-bit Unicode
equivalents. Character sets are named using their standard and common names. The local platform defines
which character set encodings are understood, but every implementation is required to support the following:


US-ASCII 7-bit ASCII, also known as ISO646-US, and as the Basic Latin block of the Unicode
character set

ISO-8859-1 ISO Latin Alphabet No. 1, also known as ISO-LATIN-1

UTF-8 8-bit Unicode Transformation Format

UTF-16BE 16-bit Unicode Transformation Format, big-endian byte order

UTF-16LE 16-bit Unicode Transformation Format, little-endian byte order

UTF-16 16-bit Unicode Transformation Format, byte order specified by a mandatory initial
byte-order mark (either order accepted on input, big-endian used on output)
Free download pdf