/** * Append a range of bytes to the end of the given text. * * @param utf8 the data to copy from * @param start the first position to append from utf8 * @param len the number of bytes to append */ public void append(byte[] utf8, int start, int len) { setCapacity(length + len, true); System.arraycopy(utf8, start, bytes, length, len); length += len; }
/** * Set the Text to range of bytes. * * @param utf8 the data to copy from * @param start the first position of the new string * @param len the number of bytes of the new string */ public void set(byte[] utf8, int start, int len) { setCapacity(len, false); System.arraycopy(utf8, start, bytes, 0, len); this.length = len; }
/** * Read a Text object whose length is already known. This allows creating Text from a stream which * uses a different serialization format. * * @param in the input to initialize from * @param len how many bytes to read from in * @throws IOException if something bad happens */ public void readWithKnownLength(DataInput in, int len) throws IOException { setCapacity(len, false); in.readFully(bytes, 0, len); length = len; }