Java Reference
In-Depth Information
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.
public
String(byte[] bytes)
Equivalent to
String(bytes, 0, bytes.length)
.
public
String(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
.
public
String(byte[] bytes, String enc)
throws UnsupportedEncod-
ingException
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 UnsupportedEncodingExcep-
tion
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
.