Package java.lang
Class String

Public Method getBytes

byte[] getBytes()

Throws:

void getBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin)

Throws:

_INSERT_METHOD_SIGNATURE_HERE_

Description:

getBytes() method:

Encodes this String into a sequence of bytes using UTF8 encoding. The result will be stored in a new byte array.

getBytes(srcBegin, srcEnd, dst, dstBegin) method:

Copies characters from this string into the destination byte array. The first character (starting with 0) is at position srcBegin, the last at position srcEnd-1. The characters, converted to bytes, are copied into the subarray of dst starting at index dstBegin. The destination array has to be big enough to hold the converted character bytes. Note that in case of UTF8 encoding only the first byte will be used.

Examples

byte[] arr = "bäü∀".getBytes(); // returns [0x62 (0xC3 0xA4) (0xC3 0xBC) (0xE2 0x88 0x80)]

"0123∀".getBytes(2, 5, arr, 0); // chars 2,3 and ∀ will be converted to bytes and inserted into
                                // arr at position 0 resulting in [0x32, 0x33, 0xE2]