Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.core
Class QByteArray

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.core.QByteArray

All Implemented Interfaces:
  QtJambiInterface, java.lang.Cloneable, java.lang.Comparable

    public class QByteArray

extends QtJambiObject
implements java.lang.Comparable, java.lang.Cloneable

The `QByteArray` class provides an array of bytes. `QByteArray` can be used to store both raw bytes (including '\0's) and traditional 8-bit '\0'-terminated strings. Using `QByteArray` is much more convenient than using `const char *`. Behind the scenes, it always ensures that the data is followed by a '\0' terminator, and uses implicit sharing (copy-on-write) to reduce memory usage and avoid needless copying of data.

In addition to `QByteArray`, Qt also provides the QString class to store string data. For most purposes, QString is the class you want to use. It stores 16-bit Unicode characters, making it easy to store non-ASCII/non-Latin-1 characters in your application. Furthermore, QString is used throughout in the Qt API. The two main cases where `QByteArray` is appropriate are when you need to store raw binary data, and when memory conservation is critical (e.g., with Qt for Embedded Linux).

One way to initialize a `QByteArray` is simply to pass a `const char *` to its constructor. For example, the following code creates a byte array of size 5 containing the data "Hello":

            QByteArray ba = new QByteArray("Hello");

Although the `size()` is 5, the byte array also maintains an extra '\0' character at the end so that if a function is used that asks for a pointer to the underlying data (e.g. a call to `data()`), the data pointed to is guaranteed to be '\0'-terminated.

`QByteArray` makes a deep copy of the `const char *` data, so you can modify it later without experiencing side effects. (If for performance reasons you don't want to take a deep copy of the character data, use QByteArray::fromRawData() instead.)

Another approach is to set the size of the array using `resize()` and to initialize the data byte per byte. `QByteArray` uses 0-based indexes, just like C++ arrays. To access the byte at a particular index position, you can use operator[](). On non-const byte arrays, operator[]() returns a reference to a byte that can be used on the left side of an assignment. For example:

            QByteArray ba;
            ba.resize(5);
            ba[0] = 0x3c;
            ba[1] = 0xb8;
            ba[2] = 0x64;
            ba[3] = 0x18;
            ba[4] = 0xca;

For read-only access, an alternative syntax is to use `at()`:

            for (int i = 0; i < ba.size(); ++i) {
                if (ba.at(i) >= 'a' && ba.at(i) <= 'f')
                    System.out.println("Found character in range [a-f]");
            }

`at()` can be faster than operator[](), because it never causes a deep copy to occur.

To extract many bytes at a time, use `left()`, `right()`, or `mid()`.

A `QByteArray` can embed '\0' bytes. The `size()` function always returns the size of the whole array, including embedded '\0' bytes. If you want to obtain the length of the data up to and excluding the first '\0' character, call qstrlen() on the byte array.

After a call to `resize()`, newly allocated bytes have undefined values. To set all the bytes to a particular value, call `fill()`.

To obtain a pointer to the actual character data, call `data()` or constData(). These functions return a pointer to the beginning of the data. The pointer is guaranteed to remain valid until a non-const function is called on the `QByteArray`. It is also guaranteed that the data ends with a '\0' byte. This '\0' byte is automatically provided by `QByteArray` and is not counted in `size()`.

`QByteArray` provides the following basic functions for modifying the byte data: `append()`, `prepend()`, `insert()`, `replace()`, and `remove()`. For example:

            QByteArray x = new QByteArray("and");
            x.prepend("rock ");         // x == "rock and"
            x.append(" roll");          // x == "rock and roll"
            x.replace(5, 3, new QByteArray("&"));       // x == "rock & roll"

The `replace()` and `remove()` functions' first two arguments are the position from which to start erasing and the number of bytes that should be erased.

When you `append()` data to a non-empty array, the array will be reallocated and the new data copied to it. You can avoid this behavior by calling `reserve()`, which preallocates a certain amount of memory. You can also call `capacity()` to find out how much memory `QByteArray` actually allocated. Data appended to an empty array is not copied.

A frequent requirement is to remove whitespace characters from a byte array ('\n', '\t', ' ', etc.). If you want to remove whitespace from both ends of a `QByteArray`, use `trimmed()`. If you want to remove whitespace from both ends and replace multiple consecutive whitespaces with a single space character within the byte array, use `simplified()`.

If you want to find all occurrences of a particular character or substring in a `QByteArray`, use `indexOf()` or `lastIndexOf()`. The former searches forward starting from a given index position, the latter searches backward. Both return the index position of the character or substring if they find it; otherwise, they return -1. For example, here's a typical loop that finds all occurrences of a particular substring:

            QByteArray ba = new QByteArray("We must be <b>bold</b>, very <b>bold</b>");
            int j = 0;
            while ((j = ba.indexOf("<b>", j)) != -1) {
                System.out.println("Found <b> tag at index position " + j);
                ++j;
            }

If you simply want to check whether a `QByteArray` contains a particular character or substring, use `contains()`. If you want to find out how many times a particular character or substring occurs in the byte array, use `count()`. If you want to replace all occurrences of a particular value with another, use one of the two-parameter `replace()` overloads.

QByteArrays can be compared using overloaded operators such as operator<(), operator<=(), operator==(), operator>=(), and so on. The comparison is based exclusively on the numeric values of the characters and is very fast, but is not what a human would expect. QString::localeAwareCompare() is a better choice for sorting user-interface strings.

For historical reasons, `QByteArray` distinguishes between a null byte array and an empty byte array. A null byte array is a byte array that is initialized using `QByteArray`'s default constructor or by passing (const char *)0 to the constructor. An empty byte array is any byte array with size 0. A null byte array is always empty, but an empty byte array isn't necessarily null:

            new QByteArray().isNull();          // returns true
            new QByteArray().isEmpty();         // returns true

            new QByteArray("").isNull();        // returns false
            new QByteArray("").isEmpty();       // returns true

            new QByteArray("abc").isNull();     // returns false
            new QByteArray("abc").isEmpty();    // returns false

All functions except `isNull()` treat null byte arrays the same as empty byte arrays. For example, `data()` returns a pointer to a '\0' character for a null byte array (not a null pointer), and QByteArray() compares equal to `QByteArray`(""). We recommend that you always use `isEmpty()` and avoid `isNull()`.

## Notes on Locale

### Number-String Conversions

Functions that perform conversions between numeric data types and strings are performed in the C locale, irrespective of the user's locale settings. Use QString to perform locale-aware conversions between numbers and strings.

### 8-bit Character Comparisons

In `QByteArray`, the notion of uppercase and lowercase and of which character is greater than or less than another character is locale dependent. This affects functions that support a case insensitive option or that compare or lowercase or uppercase their arguments. Case insensitive operations and comparisons will be accurate if both strings contain only ASCII characters. (If `$LC_CTYPE` is set, most Unix systems do "the right thing".) Functions that this affects include `contains()`, `indexOf()`, `lastIndexOf()`, operator<(), operator<=(), operator>(), operator>=(), `toLower()` and `toUpper()`.

This issue does not apply to QStrings since they represent characters using Unicode.

See also:
  QString, and `QBitArray`.

Nested Class Summary

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QByteArray()`
`QByteArray(byte[] data)` Constructs a byte array containing the bytes of array `data`.
`QByteArray(int size, byte c)` Constructs a byte array of size `size` with every byte set to character `ch`.
`QByteArray(QByteArray arg__1)` Constructs a copy of `other`.
`QByteArray(java.lang.String s)` Constructs a byte array initialized with the string `str`.

Method Summary
`QByteArray` | `append(byte other)` This function appends `other` to the end of this QByteArray.
`QByteArray` | `append(QByteArray other)` This function appends the contents of `other` to the end of this QByteArray.
`QByteArray` | `append(java.lang.String other)` This function appends the contents of `other` to the end of this QByteArray.
`byte` | `at(int i)` Returns the character at index position `i` in the byte array.
`int` | `capacity()` Returns the maximum number of bytes that can be stored in the byte array without forcing a reallocation.
`void` | `chop(int n)` Removes `n` bytes from the end of the byte array.
`void` | `clear()` Clears the contents of the byte array and makes it empty.
`QByteArray` | `clone()` This method is reimplemented for internal reasons
`boolean` | `contains(byte c)` Returns true if the byte array contains the character `ch`; otherwise returns false.
`boolean` | `contains(QByteArray a)` Returns true if the byte array contains an occurrence of the byte array `ba`; otherwise returns false.
`boolean` | `contains(java.lang.String str)` Returns true there is at least one occurrence of `str` in this QByteArray.
`int` | `count(byte c)` Returns the number of occurrences of character `ch` in the byte array.
`int` | `count(QByteArray a)` Returns the number of (potentially overlapping) occurrences of byte array `ba` in this byte array.
`int` | `count(java.lang.String str)` Returns the number of occurrences of `str` in this QByteArray.
`QNativePointer` | `data()` Returns a pointer to the data stored in the byte array.
`boolean` | `endsWith(byte c)` Returns true if this byte array ends with character `ch`; otherwise returns false.
`boolean` | `endsWith(QByteArray a)` Returns true if this byte array ends with byte array `ba`; otherwise returns false.
`boolean` | `endsWith(java.lang.String str)` Returns true if this QByteArray ends with `str`; otherwise, returns false.
`QByteArray` | `fill(byte b)` Sets every byte in the byte array to character `b`.
`QByteArray` | `fill(byte b, int size)` Sets every byte in the byte array to character `b`.
`static QByteArray` | `fromBase64(QByteArray base64)` Returns a decoded copy of the Base64 array `base64`.
`static QByteArray` | `fromHex(QByteArray hexEncoded)` Returns a decoded copy of the hex encoded array `hexEncoded`.
`static QByteArray` | `fromPercentEncoding(QByteArray pctEncoded)` Returns a decoded copy of the URI/URL-style percent-encoded `input`.
`static QByteArray` | `fromPercentEncoding(QByteArray pctEncoded, byte percent)` Returns a decoded copy of the URI/URL-style percent-encoded `input`.
`int` | `indexOf(byte c)` Returns the index position of the first occurrence of the character `ch` in the byte array, searching forward from index position `from`.
`int` | `indexOf(byte c, int from)` Returns the index position of the first occurrence of the character `ch` in the byte array, searching forward from index position `from`.
`int` | `indexOf(QByteArray a)` Returns the index position of the first occurrence of the byte array `ba` in this byte array, searching forward from index position `from`.
`int` | `indexOf(QByteArray a, int from)` Returns the index position of the first occurrence of the byte array `ba` in this byte array, searching forward from index position `from`.
`int` | `indexOf(java.lang.String s)` Returns the index position of the first occurrence of the string `str` in the byte array, searching forward from index position `from`.
`int` | `indexOf(java.lang.String s, int from)` Returns the index position of the first occurrence of the string `str` in the byte array, searching forward from index position `from`.
`QByteArray` | `insert(int i, byte b)` Inserts byte `b` at index position `i` in the byte array.
`QByteArray` | `insert(int i, QByteArray ba)` Inserts the byte array `ba` at index position `i` and returns a reference to this byte array.
`QByteArray` | `insert(int i, java.lang.String str)` Inserts String `str` at index position `i` in the byte array.
`boolean` | `isEmpty()` Returns true if the byte array has size 0; otherwise returns false.
`boolean` | `isNull()` Returns true if this byte array is null; otherwise returns false.
`int` | `lastIndexOf(byte c)` Returns the index position of the last occurrence of character `ch` in the byte array, searching backward from index position `from`.
`int` | `lastIndexOf(byte c, int from)` Returns the index position of the last occurrence of character `ch` in the byte array, searching backward from index position `from`.
`int` | `lastIndexOf(QByteArray a)` Returns the index position of the last occurrence of the byte array `ba` in this byte array, searching backward from index position `from`.
`int` | `lastIndexOf(QByteArray a, int from)` Returns the index position of the last occurrence of the byte array `ba` in this byte array, searching backward from index position `from`.
`int` | `lastIndexOf(java.lang.String s)` Returns the index position of the last occurrence of the string `str` in the byte array, searching backward from index position `from`.
`int` | `lastIndexOf(java.lang.String s, int from)` Returns the index position of the last occurrence of the string `str` in the byte array, searching backward from index position `from`.
`QByteArray` | `left(int len)` Returns a byte array that contains the leftmost `len` bytes of this byte array.
`QByteArray` | `leftJustified(int width)` Returns a byte array of size `width` that contains this byte array padded by the `fill` character.
`QByteArray` | `leftJustified(int width, byte fill)` Returns a byte array of size `width` that contains this byte array padded by the `fill` character.
`QByteArray` | `leftJustified(int width, byte fill, boolean truncate)` Returns a byte array of size `width` that contains this byte array padded by the `fill` character.
`int` | `length()` Same as `size()`.
`QByteArray` | `mid(int index)` Returns a byte array containing `len` bytes from this byte array, starting at position `pos`.
`QByteArray` | `mid(int index, int len)` Returns a byte array containing `len` bytes from this byte array, starting at position `pos`.
`static QByteArray` | `number(double arg__1)` Returns a byte array that contains the printed value of `n`, formatted in format `f` with precision `prec`.
`static QByteArray` | `number(double arg__1, byte f)` Returns a byte array that contains the printed value of `n`, formatted in format `f` with precision `prec`.
`static QByteArray` | `number(double arg__1, byte f, int prec)` Returns a byte array that contains the printed value of `n`, formatted in format `f` with precision `prec`.
`static QByteArray` | `number(int arg__1)` Returns a byte array containing the string equivalent of the number `n` to base `base` (10 by default).
`static QByteArray` | `number(int arg__1, int base)` Returns a byte array containing the string equivalent of the number `n` to base `base` (10 by default).
`static QByteArray` | `number(long arg__1)` See also. toLongLong().
`static QByteArray` | `number(long arg__1, int base)` Returns a byte array containing the string equivalent of the number `arg__1` to base `base`.
`QByteArray` | `prepend(byte other)` Prepends `other` to this QByteArray, and returns the resulting array.
`QByteArray` | `prepend(QByteArray other)` Prepends `other` to this QByteArray, and returns the resulting array.
`QByteArray` | `prepend(java.lang.String str)` Prepends `str` to this QByteArray, and returns the resulting array.
`void` | `readFrom(QDataStream arg__1)` Reads a QByteArray
`QByteArray` | `remove(int pos, int len)` Removes `len` bytes from the array, starting at index position `pos`, and returns a reference to the array.
`QByteArray` | `replace(byte before, byte after)` Replaces every occurrence of `before` with `after`.
`QByteArray` | `replace(byte before, QByteArray after)` Replaces every occurrence of `before` with `after`.
`QByteArray` | `replace(byte before, java.lang.String after)` Replaces every occurrence of `before` with `after`.
`QByteArray` | `replace(int pos, int len, QByteArray after)` Replaces every occurrence of `before` with `after`.
`QByteArray` | `replace(QByteArray before, QByteArray after)` Replaces every occurrence of `before` with `after`.
`QByteArray` | `replace(QByteArray before, java.lang.String after)` Replaces every occurrence of the byte array `before` with the string `after`.
`QByteArray` | `replace(java.lang.String before, QByteArray after)` Replaces every occurrence of `before` with `after`.
`QByteArray` | `replace(java.lang.String before, java.lang.String after)` Replaces every occurrence of `before` with `after`.
`void` | `reserve(int size)` Attempts to allocate memory for at least `size` bytes.
`void` | `resize(int size)` Sets the size of the byte array to `size` bytes.
`QByteArray` | `right(int len)` Returns a byte array that contains the rightmost `len` bytes of this byte array.
`QByteArray` | `rightJustified(int width)` Returns a byte array of size `width` that contains the `fill` character followed by this byte array.
`QByteArray` | `rightJustified(int width, byte fill)` Returns a byte array of size `width` that contains the `fill` character followed by this byte array.
`QByteArray` | `rightJustified(int width, byte fill, boolean truncate)` Returns a byte array of size `width` that contains the `fill` character followed by this byte array.
`QByteArray` | `set(QByteArray other)` This function sets the contents of this QByteArray equal to `other`.
`QByteArray` | `setNum(char n)` See also. toUShort().
`QByteArray` | `setNum(char n, int base)` See also. toShort().
`QByteArray` | `setNum(double n)` This is an overloaded function provided for convenience.
`QByteArray` | `setNum(double n, char f)` This is an overloaded function provided for convenience.
`QByteArray` | `setNum(double n, char f, int prec)` Sets the byte array to the printed value of `n`, formatted in format `f` with precision `prec`, and returns a reference to the byte array.
`QByteArray` | `setNum(float n)` Sets the byte array to the printed value of `n`, formatted in format `f` with precision 6, and returns a reference to the byte array.
`QByteArray` | `setNum(float n, char f)` Sets the byte array to the printed value of `n`, formatted in format `f` with precision 6, and returns a reference to the byte array.
`QByteArray` | `setNum(float n, char f, int prec)` Sets the byte array to the printed value of `n`, formatted in format `f` with precision `prec`, and returns a reference to the byte array.
`QByteArray` | `setNum(int n)` Sets the array to the printed value of `n`
`QByteArray` | `setNum(int n, int base)` Sets the array to the printed value of `n` using `base` as base.
`QByteArray` | `setNum(long n)` This is an overloaded function provided for convenience.
`QByteArray` | `setNum(long n, int base)` This is an overloaded function provided for convenience.
`QByteArray` | `setNum(short n)` This is an overloaded function provided for convenience.
`QByteArray` | `setNum(short n, int base)` This is an overloaded function provided for convenience.
`QByteArray` | `simplified()` Returns a byte array that has whitespace removed from the start and the end, and which has each sequence of internal whitespace replaced with a single space.
`int` | `size()` Returns the number of bytes in this byte array.
`java.util.List` | `split(byte sep)` Splits the byte array into subarrays wherever `sep` occurs, and returns the list of those arrays.
`void` | `squeeze()` Releases any memory not required to store the array's data.
`boolean` | `startsWith(byte c)` Returns true if this byte array starts with character `ch`; otherwise returns false.
`boolean` | `startsWith(QByteArray a)` Returns true if this byte array starts with byte array `ba`; otherwise returns false.
`boolean` | `startsWith(java.lang.String str)` Returns true if this byte array starts with string `str`; otherwise returns false.
`QByteArray` | `toBase64()` Returns a copy of the byte array, encoded as Base64.
`byte[]` | `toByteArray()` Returns the contents of this QByteArray.
`char` | `toChar()` Returns the byte array converted to a char.
`char` | `toChar(int base)` Returns the byte array converted to an char using base `base`, which is 10 by default and must be between 2 and 36, or 0.
`double` | `toDouble()` Returns the byte array converted to an double.
`float` | `toFloat()` Returns the byte array converted to an float.
`QByteArray` | `toHex()` Returns a hex encoded copy of the byte array.
`int` | `toInt()` Returns the byte array converted to an int using base 10.
`int` | `toInt(int base)` Returns the byte array converted to an int using base `base`, which is 10 by default and must be between 2 and 36, or 0.
`QByteArray` | `toLower()` Returns a lowercase copy of the byte array.
`QByteArray` | `toPercentEncoding()` Returns a URI/URL-style percent-encoded copy of this byte array.
`QByteArray` | `toPercentEncoding(QByteArray exclude)` Returns a URI/URL-style percent-encoded copy of this byte array.
`QByteArray` | `toPercentEncoding(QByteArray exclude, QByteArray include)` Returns a URI/URL-style percent-encoded copy of this byte array.
`QByteArray` | `toPercentEncoding(QByteArray exclude, QByteArray include, byte percent)` Returns a URI/URL-style percent-encoded copy of this byte array.
`java.lang.String` | `toString()` Returns a string representation of the `this QByteArray`.
`QByteArray` | `toUpper()` Returns an uppercase copy of the byte array.
`QByteArray` | `trimmed()` Returns a byte array that has whitespace removed from the start and the end.
`void` | `truncate(int pos)` Truncates the byte array at index position `pos`.
`void` | `writeTo(QDataStream arg__1)` Writes thisQByteArray

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

Methods inherited from class java.lang.Object
`getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface java.lang.Comparable
`compareTo`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Constructor Detail

### QByteArray

    public QByteArray()

### QByteArray

    public QByteArray(QByteArray arg__1)

  Constructs a copy of `other`.

  This operation takes constant time, because `QByteArray` is implicitly shared. This makes returning a `QByteArray` from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and that takes linear time.

See also:
  operator=().

### QByteArray

    public QByteArray(int size,
                      byte c)

  Constructs a byte array of size `size` with every byte set to character `ch`.

See also:
  `fill()`.

### QByteArray

    public QByteArray(java.lang.String s)

  Constructs a byte array initialized with the string `str`.

  QByteArray makes a deep copy of the string data.

### QByteArray

    public QByteArray(byte[] data)

  Constructs a byte array containing the bytes of array `data`.

  If `data` is null, a null byte array is constructed.

  `QByteArray` makes a deep copy of the string data.

See also:
  fromRawData().

Method Detail

### at

    public final byte at(int i)

  Returns the character at index position `i` in the byte array.

  `i` must be a valid index position in the byte array (i.e., 0 <= `i` < `size()`).

See also:
  operator[]().

### capacity

    public final int capacity()

  Returns the maximum number of bytes that can be stored in the byte array without forcing a reallocation.

  The sole purpose of this function is to provide a means of fine tuning `QByteArray`'s memory usage. In general, you will rarely ever need to call this function. If you want to know how many bytes are in the byte array, call `size()`.

See also:
  `reserve()`, and `squeeze()`.

### chop

    public final void chop(int n)

  Removes `n` bytes from the end of the byte array.

  If `n` is greater than `size()`, the result is an empty byte array.

  Example:

              QByteArray ba = new QByteArray("STARTTLS\r\n");
              ba.chop(2);                 // ba == "STARTTLS"

See also:
  `truncate()`, `resize()`, and `left()`.

### clear

    public final void clear()

  Clears the contents of the byte array and makes it empty.

See also:
  `resize()`, and `isEmpty()`.

### contains

    public final boolean contains(byte c)

  Returns true if the byte array contains the character `ch`; otherwise returns false.

### contains

    public final boolean contains(QByteArray a)

  Returns true if the byte array contains an occurrence of the byte array `ba`; otherwise returns false.

See also:
  `indexOf()`, and `count()`.

### count

    public final int count(byte c)

  Returns the number of occurrences of character `ch` in the byte array.

See also:
  `contains()`, and `indexOf()`.

### count

    public final int count(QByteArray a)

  Returns the number of (potentially overlapping) occurrences of byte array `ba` in this byte array.

See also:
  `contains()`, and `indexOf()`.

### data

    public final QNativePointer data()

  Returns a pointer to the data stored in the byte array. The pointer can be used to access and modify the bytes that compose the array. The data is '\0'-terminated.

  Example:

              QByteArray ba = new QByteArray("Hello world");
              QNativePointer data = ba.data();

              int i = 0;
              while (data.byteAt(i) != 0) {
                  System.out.println("[" + data.byteAt(i) + "]");
                  ++i;
              }

  The pointer remains valid as long as the byte array isn't reallocated or destroyed. For read-only access, constData() is faster because it never causes a deep copy to occur.

  This function is mostly useful to pass a byte array to a function that accepts a `const char *`.

  Note: A `QByteArray` can store any byte values including '\0's, but most functions that take `char *` arguments assume that the data ends at the first '\0' they encounter.

See also:
  constData(), and operator[]().

### endsWith

    public final boolean endsWith(byte c)

  Returns true if this byte array ends with character `ch`; otherwise returns false.

### endsWith

    public final boolean endsWith(QByteArray a)

  Returns true if this byte array ends with byte array `ba`; otherwise returns false.

  Example:

              QByteArray url = new QByteArray("http://www.trolltech.com/index.html");
              if (url.endsWith(".html"))
                  System.out.println("foo");
                  // ...

See also:
  `startsWith()`, and `right()`.

### indexOf

    public final int indexOf(byte c)

  Returns the index position of the first occurrence of the character `ch` in the byte array, searching forward from index position `from`. Returns -1 if `ch` could not be found.

  Example:

              QByteArray ba = new QByteArray("ABCBA");
              ba.indexOf("B");            // returns 1
              ba.indexOf("B", 1);         // returns 1
              ba.indexOf("B", 2);         // returns 3
              ba.indexOf("X");            // returns -1

See also:
  `lastIndexOf()`, and `contains()`.

### indexOf

    public final int indexOf(byte c,
                             int from)

  Returns the index position of the first occurrence of the character `ch` in the byte array, searching forward from index position `from`. Returns -1 if `ch` could not be found.

  Example:

              QByteArray ba = new QByteArray("ABCBA");
              ba.indexOf("B");            // returns 1
              ba.indexOf("B", 1);         // returns 1
              ba.indexOf("B", 2);         // returns 3
              ba.indexOf("X");            // returns -1

See also:
  `lastIndexOf()`, and `contains()`.

### indexOf

    public final int indexOf(QByteArray a)

  Returns the index position of the first occurrence of the byte array `ba` in this byte array, searching forward from index position `from`. Returns -1 if `ba` could not be found.

  Example:

              QByteArray x = new QByteArray("sticky question");
              QByteArray y = new QByteArray("sti");
              x.indexOf(y);               // returns 0
              x.indexOf(y, 1);            // returns 10
              x.indexOf(y, 10);           // returns 10
              x.indexOf(y, 11);           // returns -1

See also:
  `lastIndexOf()`, `contains()`, and `count()`.

### indexOf

    public final int indexOf(QByteArray a,
                             int from)

  Returns the index position of the first occurrence of the byte array `ba` in this byte array, searching forward from index position `from`. Returns -1 if `ba` could not be found.

  Example:

              QByteArray x = new QByteArray("sticky question");
              QByteArray y = new QByteArray("sti");
              x.indexOf(y);               // returns 0
              x.indexOf(y, 1);            // returns 10
              x.indexOf(y, 10);           // returns 10
              x.indexOf(y, 11);           // returns -1

See also:
  `lastIndexOf()`, `contains()`, and `count()`.

### indexOf

    public final int indexOf(java.lang.String s)

  Returns the index position of the first occurrence of the string `str` in the byte array, searching forward from index position `from`. Returns -1 if `str` could not be found.

  The Unicode data is converted into 8-bit characters using QString::toAscii().

  If the QString contains non-ASCII Unicode characters, using this function can lead to loss of information. You can disable this function by defining `QT_NO_CAST_TO_ASCII` when you compile your applications. You then need to call QString::toAscii() (or QString::toLatin1() or QString::toUtf8() or QString::toLocal8Bit()) explicitly if you want to convert the data to `const char *`.

### indexOf

    public final int indexOf(java.lang.String s,
                             int from)

  Returns the index position of the first occurrence of the string `str` in the byte array, searching forward from index position `from`. Returns -1 if `str` could not be found.

  The Unicode data is converted into 8-bit characters using QString::toAscii().

  If the QString contains non-ASCII Unicode characters, using this function can lead to loss of information. You can disable this function by defining `QT_NO_CAST_TO_ASCII` when you compile your applications. You then need to call QString::toAscii() (or QString::toLatin1() or QString::toUtf8() or QString::toLocal8Bit()) explicitly if you want to convert the data to `const char *`.

### isEmpty

    public final boolean isEmpty()

  Returns true if the byte array has size 0; otherwise returns false.

  Example:

              new QByteArray().isEmpty();         // returns true
              new QByteArray("").isEmpty();       // returns true
              new QByteArray("abc").isEmpty();    // returns false

See also:
  `size()`.

### isNull

    public final boolean isNull()

  Returns true if this byte array is null; otherwise returns false.

  Example:

              new QByteArray().isNull();          // returns true
              new QByteArray("").isNull();        // returns false
              new QByteArray("abc").isNull();     // returns false

  Qt makes a distinction between null byte arrays and empty byte arrays for historical reasons. For most applications, what matters is whether or not a byte array contains any data, and this can be determined using `isEmpty()`.

See also:
  `isEmpty()`.

### lastIndexOf

    public final int lastIndexOf(byte c)

  Returns the index position of the last occurrence of character `ch` in the byte array, searching backward from index position `from`. If `from` is -1 (the default), the search starts at the last (`size()` - 1) byte. Returns -1 if `ch` could not be found.

  Example:

              QByteArray ba = new QByteArray("ABCBA");
              ba.lastIndexOf("B");        // returns 3
              ba.lastIndexOf("B", 3);     // returns 3
              ba.lastIndexOf("B", 2);     // returns 1
              ba.lastIndexOf("X");        // returns -1

See also:
  `indexOf()`, and `contains()`.

### lastIndexOf

    public final int lastIndexOf(byte c,
                                 int from)

  Returns the index position of the last occurrence of character `ch` in the byte array, searching backward from index position `from`. If `from` is -1 (the default), the search starts at the last (`size()` - 1) byte. Returns -1 if `ch` could not be found.

  Example:

              QByteArray ba = new QByteArray("ABCBA");
              ba.lastIndexOf("B");        // returns 3
              ba.lastIndexOf("B", 3);     // returns 3
              ba.lastIndexOf("B", 2);     // returns 1
              ba.lastIndexOf("X");        // returns -1

See also:
  `indexOf()`, and `contains()`.

### lastIndexOf

    public final int lastIndexOf(QByteArray a)

  Returns the index position of the last occurrence of the byte array `ba` in this byte array, searching backward from index position `from`. If `from` is -1 (the default), the search starts at the last byte. Returns -1 if `ba` could not be found.

  Example:

              QByteArray x = new QByteArray("crazy azimuths");
              QByteArray y = new QByteArray("azy");
              x.lastIndexOf(y);           // returns 6
              x.lastIndexOf(y, 6);        // returns 6
              x.lastIndexOf(y, 5);        // returns 2
              x.lastIndexOf(y, 1);        // returns -1

See also:
  `indexOf()`, `contains()`, and `count()`.

### lastIndexOf

    public final int lastIndexOf(QByteArray a,
                                 int from)

  Returns the index position of the last occurrence of the byte array `ba` in this byte array, searching backward from index position `from`. If `from` is -1 (the default), the search starts at the last byte. Returns -1 if `ba` could not be found.

  Example:

              QByteArray x = new QByteArray("crazy azimuths");
              QByteArray y = new QByteArray("azy");
              x.lastIndexOf(y);           // returns 6
              x.lastIndexOf(y, 6);        // returns 6
              x.lastIndexOf(y, 5);        // returns 2
              x.lastIndexOf(y, 1);        // returns -1

See also:
  `indexOf()`, `contains()`, and `count()`.

### lastIndexOf

    public final int lastIndexOf(java.lang.String s)

  Returns the index position of the last occurrence of the string `str` in the byte array, searching backward from index position `from`. If `from` is -1 (the default), the search starts at the last (`size()` - 1) byte. Returns -1 if `str` could not be found.

  The Unicode data is converted into 8-bit characters using QString::toAscii().

  If the QString contains non-ASCII Unicode characters, using this function can lead to loss of information. You can disable this function by defining `QT_NO_CAST_TO_ASCII` when you compile your applications. You then need to call QString::toAscii() (or QString::toLatin1() or QString::toUtf8() or QString::toLocal8Bit()) explicitly if you want to convert the data to `const char *`.

### lastIndexOf

    public final int lastIndexOf(java.lang.String s,
                                 int from)

  Returns the index position of the last occurrence of the string `str` in the byte array, searching backward from index position `from`. If `from` is -1 (the default), the search starts at the last (`size()` - 1) byte. Returns -1 if `str` could not be found.

  The Unicode data is converted into 8-bit characters using QString::toAscii().

  If the QString contains non-ASCII Unicode characters, using this function can lead to loss of information. You can disable this function by defining `QT_NO_CAST_TO_ASCII` when you compile your applications. You then need to call QString::toAscii() (or QString::toLatin1() or QString::toUtf8() or QString::toLocal8Bit()) explicitly if you want to convert the data to `const char *`.

### left

    public final QByteArray left(int len)

  Returns a byte array that contains the leftmost `len` bytes of this byte array.

  The entire byte array is returned if `len` is greater than `size()`.

  Example:

              QByteArray x = new QByteArray("Pineapple");
              QByteArray y = x.left(4);
              // y == "Pine"

See also:
  `right()`, `mid()`, `startsWith()`, and `truncate()`.

### leftJustified

    public final QByteArray leftJustified(int width,
                                          byte fill)

  Returns a byte array of size `width` that contains this byte array padded by the `fill` character.

  If `truncate` is false and the `size()` of the byte array is more than `width`, then the returned byte array is a copy of this byte array.

  If `truncate` is true and the `size()` of the byte array is more than `width`, then any bytes in a copy of the byte array after position `width` are removed, and the copy is returned.

  Example:

              QByteArray x = new QByteArray("apple");
              QByteArray y = x.leftJustified(8, (byte)'.', false);   // y == "apple..."

See also:
  `rightJustified()`.

### leftJustified

    public final QByteArray leftJustified(int width)

  Returns a byte array of size `width` that contains this byte array padded by the `fill` character.

  If `truncate` is false and the `size()` of the byte array is more than `width`, then the returned byte array is a copy of this byte array.

  If `truncate` is true and the `size()` of the byte array is more than `width`, then any bytes in a copy of the byte array after position `width` are removed, and the copy is returned.

  Example:

              QByteArray x = new QByteArray("apple");
              QByteArray y = x.leftJustified(8, (byte)'.', false);   // y == "apple..."

See also:
  `rightJustified()`.

### leftJustified

    public final QByteArray leftJustified(int width,
                                          byte fill,
                                          boolean truncate)

  Returns a byte array of size `width` that contains this byte array padded by the `fill` character.

  If `truncate` is false and the `size()` of the byte array is more than `width`, then the returned byte array is a copy of this byte array.

  If `truncate` is true and the `size()` of the byte array is more than `width`, then any bytes in a copy of the byte array after position `width` are removed, and the copy is returned.

  Example:

              QByteArray x = new QByteArray("apple");
              QByteArray y = x.leftJustified(8, (byte)'.', false);   // y == "apple..."

See also:
  `rightJustified()`.

### length

    public final int length()

  Same as `size()`.

### mid

    public final QByteArray mid(int index)

  Returns a byte array containing `len` bytes from this byte array, starting at position `pos`.

  If `len` is -1 (the default), or `pos` + `len` >= `size()`, returns a byte array containing all bytes starting at position `pos` until the end of the byte array.

  Example:

              QByteArray x = new QByteArray("Five pineapples");
              QByteArray y = x.mid(5, 4);     // y == "pine"
              QByteArray z = x.mid(5);        // z == "pineapples"

See also:
  `left()`, and `right()`.

### mid

    public final QByteArray mid(int index,
                                int len)

  Returns a byte array containing `len` bytes from this byte array, starting at position `pos`.

  If `len` is -1 (the default), or `pos` + `len` >= `size()`, returns a byte array containing all bytes starting at position `pos` until the end of the byte array.

  Example:

              QByteArray x = new QByteArray("Five pineapples");
              QByteArray y = x.mid(5, 4);     // y == "pine"
              QByteArray z = x.mid(5);        // z == "pineapples"

See also:
  `left()`, and `right()`.

### writeTo

    public final void writeTo(QDataStream arg__1)

  Writes thisQByteArray

### readFrom

    public final void readFrom(QDataStream arg__1)

  Reads a QByteArray

### reserve

    public final void reserve(int size)

  Attempts to allocate memory for at least `size` bytes. If you know in advance how large the byte array will be, you can call this function, and if you call `resize()` often you are likely to get better performance. If `size` is an underestimate, the worst that will happen is that the `QByteArray` will be a bit slower.

  The sole purpose of this function is to provide a means of fine tuning `QByteArray`'s memory usage. In general, you will rarely ever need to call this function. If you want to change the size of the byte array, call `resize()`.

See also:
  `squeeze()`, and `capacity()`.

### resize

    public final void resize(int size)

  Sets the size of the byte array to `size` bytes.

  If `size` is greater than the current size, the byte array is extended to make it `size` bytes with the extra bytes added to the end. The new bytes are uninitialized.

  If `size` is less than the current size, bytes are removed from the end.

See also:
  `size()`.

### right

    public final QByteArray right(int len)

  Returns a byte array that contains the rightmost `len` bytes of this byte array.

  The entire byte array is returned if `len` is greater than `size()`.

  Example:

              QByteArray x = new QByteArray("Pineapple");
              QByteArray y = x.right(5);
              // y == "apple"

See also:
  `endsWith()`, `left()`, and `mid()`.

### rightJustified

    public final QByteArray rightJustified(int width,
                                           byte fill)

  Returns a byte array of size `width` that contains the `fill` character followed by this byte array.

  If `truncate` is false and the size of the byte array is more than `width`, then the returned byte array is a copy of this byte array.

  If `truncate` is true and the size of the byte array is more than `width`, then the resulting byte array is truncated at position `width`.

  Example:

              QByteArray x = new QByteArray("apple");
              QByteArray y = x.rightJustified(8, (byte)'.', false);    // y == "...apple"

See also:
  `leftJustified()`.

### rightJustified

    public final QByteArray rightJustified(int width)

  Returns a byte array of size `width` that contains the `fill` character followed by this byte array.

  If `truncate` is false and the size of the byte array is more than `width`, then the returned byte array is a copy of this byte array.

  If `truncate` is true and the size of the byte array is more than `width`, then the resulting byte array is truncated at position `width`.

  Example:

              QByteArray x = new QByteArray("apple");
              QByteArray y = x.rightJustified(8, (byte)'.', false);    // y == "...apple"

See also:
  `leftJustified()`.

### rightJustified

    public final QByteArray rightJustified(int width,
                                           byte fill,
                                           boolean truncate)

  Returns a byte array of size `width` that contains the `fill` character followed by this byte array.

  If `truncate` is false and the size of the byte array is more than `width`, then the returned byte array is a copy of this byte array.

  If `truncate` is true and the size of the byte array is more than `width`, then the resulting byte array is truncated at position `width`.

  Example:

              QByteArray x = new QByteArray("apple");
              QByteArray y = x.rightJustified(8, (byte)'.', false);    // y == "...apple"

See also:
  `leftJustified()`.

### simplified

    public final QByteArray simplified()

  Returns a byte array that has whitespace removed from the start and the end, and which has each sequence of internal whitespace replaced with a single space.

  Whitespace means any character for which the standard C++ isspace() function returns true. This includes the ASCII characters '\t', '\n', '\v', '\f', '\r', and ' '.

  Example:

              QByteArray ba = new QByteArray("  lots\t of\nwhitespace\r\n ");
              ba = ba.simplified();
              // ba == "lots of whitespace";

See also:
  `trimmed()`.

### size

    public final int size()

  Returns the number of bytes in this byte array.

  The last byte in the byte array is at position `size()` - 1. In addition, `QByteArray` ensures that the byte at position `size()` is always '\0', so that you can use the return value of `data()` and constData() as arguments to functions that expect '\0'-terminated strings.

  Example:

              QByteArray ba = new QByteArray("Hello");
              int n = ba.size();          // n == 5
              byte a = ba.at(0);               // returns 'H'
              byte b = ba.at(4);               // returns 'o'
              byte c = ba.at(5);               // returns '\0'

See also:
  `isEmpty()`, and `resize()`.

### split

    public final java.util.List split(byte sep)

  Splits the byte array into subarrays wherever `sep` occurs, and returns the list of those arrays. If `sep` does not match anywhere in the byte array, `split()` returns a single-element list containing this byte array.

### squeeze

    public final void squeeze()

  Releases any memory not required to store the array's data.

  The sole purpose of this function is to provide a means of fine tuning `QByteArray`'s memory usage. In general, you will rarely ever need to call this function.

See also:
  `reserve()`, and `capacity()`.

### startsWith

    public final boolean startsWith(byte c)

  Returns true if this byte array starts with character `ch`; otherwise returns false.

### startsWith

    public final boolean startsWith(QByteArray a)

  Returns true if this byte array starts with byte array `ba`; otherwise returns false.

  Example:

              QByteArray url = new QByteArray("ftp://ftp.trolltech.com/");
              if (url.startsWith("ftp:"))
                  System.out.println("foo");
                  // ...

See also:
  `endsWith()`, and `left()`.

### toBase64

    public final QByteArray toBase64()

  Returns a copy of the byte array, encoded as Base64.

              QByteArray text = new QByteArray("Qt is great!");
              text.toBase64();        // returns "UXQgaXMgZ3JlYXQh"

  The algorithm used to encode Base64-encoded data is defined in RFC 2045.

See also:
  `fromBase64()`.

### toHex

    public final QByteArray toHex()

  Returns a hex encoded copy of the byte array. The hex encoding uses the numbers 0-9 and the letters a-f.

See also:
  `fromHex()`.

### toLower

    public final QByteArray toLower()

  Returns a lowercase copy of the byte array. The bytearray is interpreted as a Latin-1 encoded string.

  Example:

              QByteArray x = new QByteArray("TROlltECH");
              QByteArray y = x.toLower();
              // y == "trolltech"

See also:
  `toUpper()`, and `8-bit Character Comparisons`.

### toPercentEncoding

    public final QByteArray toPercentEncoding(QByteArray exclude,
                                              QByteArray include)

  Returns a URI/URL-style percent-encoded copy of this byte array. The `percent` parameter allows you to override the default '%' character for another.

  By default, this function will encode all characters that are not one of the following:

  ALPHA ("a" to "z" and "A" to "Z") / DIGIT (0 to 9) / "-" / "." / "_" / "~"

  To prevent characters from being encoded pass them to `exclude`. To force characters to be encoded pass them to `include`. The `percent` character is always encoded.

  Example:

      QByteArray text = "{a fishy string?}";
      QByteArray ba = text.toPercentEncoding("{}", "s");
      qDebug(ba.constData());
      // prints "{a fi%73hy %73tring%3F}"

  The hex encoding uses the numbers 0-9 and the uppercase letters A-F.

See also:
  `fromPercentEncoding()`, and `QUrl::toPercentEncoding()`.

### toPercentEncoding

    public final QByteArray toPercentEncoding(QByteArray exclude)

  Returns a URI/URL-style percent-encoded copy of this byte array. The `percent` parameter allows you to override the default '%' character for another.

  By default, this function will encode all characters that are not one of the following:

  ALPHA ("a" to "z" and "A" to "Z") / DIGIT (0 to 9) / "-" / "." / "_" / "~"

  To prevent characters from being encoded pass them to `exclude`. To force characters to be encoded pass them to `include`. The `percent` character is always encoded.

  Example:

      QByteArray text = "{a fishy string?}";
      QByteArray ba = text.toPercentEncoding("{}", "s");
      qDebug(ba.constData());
      // prints "{a fi%73hy %73tring%3F}"

  The hex encoding uses the numbers 0-9 and the uppercase letters A-F.

See also:
  `fromPercentEncoding()`, and `QUrl::toPercentEncoding()`.

### toPercentEncoding

    public final QByteArray toPercentEncoding()

  Returns a URI/URL-style percent-encoded copy of this byte array. The `percent` parameter allows you to override the default '%' character for another.

  By default, this function will encode all characters that are not one of the following:

  ALPHA ("a" to "z" and "A" to "Z") / DIGIT (0 to 9) / "-" / "." / "_" / "~"

  To prevent characters from being encoded pass them to `exclude`. To force characters to be encoded pass them to `include`. The `percent` character is always encoded.

  Example:

      QByteArray text = "{a fishy string?}";
      QByteArray ba = text.toPercentEncoding("{}", "s");
      qDebug(ba.constData());
      // prints "{a fi%73hy %73tring%3F}"

  The hex encoding uses the numbers 0-9 and the uppercase letters A-F.

See also:
  `fromPercentEncoding()`, and `QUrl::toPercentEncoding()`.

### toPercentEncoding

    public final QByteArray toPercentEncoding(QByteArray exclude,
                                              QByteArray include,
                                              byte percent)

  Returns a URI/URL-style percent-encoded copy of this byte array. The `percent` parameter allows you to override the default '%' character for another.

  By default, this function will encode all characters that are not one of the following:

  ALPHA ("a" to "z" and "A" to "Z") / DIGIT (0 to 9) / "-" / "." / "_" / "~"

  To prevent characters from being encoded pass them to `exclude`. To force characters to be encoded pass them to `include`. The `percent` character is always encoded.

  Example:

      QByteArray text = "{a fishy string?}";
      QByteArray ba = text.toPercentEncoding("{}", "s");
      qDebug(ba.constData());
      // prints "{a fi%73hy %73tring%3F}"

  The hex encoding uses the numbers 0-9 and the uppercase letters A-F.

See also:
  `fromPercentEncoding()`, and `QUrl::toPercentEncoding()`.

### toUpper

    public final QByteArray toUpper()

  Returns an uppercase copy of the byte array. The bytearray is interpreted as a Latin-1 encoded string.

  Example:

              QByteArray x = new QByteArray("TROlltECH");
              QByteArray y = x.toUpper();
              // y == "TROLLTECH"

See also:
  `toLower()`, and `8-bit Character Comparisons`.

### trimmed

    public final QByteArray trimmed()

  Returns a byte array that has whitespace removed from the start and the end.

  Whitespace means any character for which the standard C++ isspace() function returns true. This includes the ASCII characters '\t', '\n', '\v', '\f', '\r', and ' '.

  Example:

              QByteArray ba = new QByteArray("  lots\t of\nwhitespace\r\n ");
              ba = ba.trimmed();
              // ba == "lots\t of\nwhitespace";

  Unlike `simplified()`, `trimmed()` leaves internal whitespace alone.

See also:
  `simplified()`.

### truncate

    public final void truncate(int pos)

  Truncates the byte array at index position `pos`.

  If `pos` is beyond the end of the array, nothing happens.

  Example:

              QByteArray ba = new QByteArray("Stockholm");
              ba.truncate(5);             // ba == "Stock"

See also:
  `chop()`, `resize()`, and `left()`.

### fromBase64

    public static QByteArray fromBase64(QByteArray base64)

  Returns a decoded copy of the Base64 array `base64`. Input is not checked for validity; invalid characters in the input are skipped, enabling the decoding process to continue with subsequent characters.

  For example:

              QByteArray text = QByteArray.fromBase64(new QByteArray("UXQgaXMgZ3JlYXQh"));
              text.data();            // returns "Qt is great!"

  The algorithm used to decode Base64-encoded data is defined in RFC 2045.

See also:
  `toBase64()`.

### fromHex

    public static QByteArray fromHex(QByteArray hexEncoded)

  Returns a decoded copy of the hex encoded array `hexEncoded`. Input is not checked for validity; invalid characters in the input are skipped, enabling the decoding process to continue with subsequent characters.

  For example:

              QByteArray text = QByteArray.fromHex(new QByteArray("517420697320677265617421"));
              text.data();            // returns "Qt is great!"

See also:
  `toHex()`.

### fromPercentEncoding

    public static QByteArray fromPercentEncoding(QByteArray pctEncoded)

  Returns a decoded copy of the URI/URL-style percent-encoded `input`. The `percent` parameter allows you to replace the '%' character for another (for instance, '_' or '=').

  For example:

      QByteArray text = QByteArray::fromPercentEncoding("Qt%20is%20great%33");
      text.data();            // returns "Qt is great!"

See also:
  `toPercentEncoding()`, and `QUrl::fromPercentEncoding()`.

### fromPercentEncoding

    public static QByteArray fromPercentEncoding(QByteArray pctEncoded,
                                                 byte percent)

  Returns a decoded copy of the URI/URL-style percent-encoded `input`. The `percent` parameter allows you to replace the '%' character for another (for instance, '_' or '=').

  For example:

      QByteArray text = QByteArray::fromPercentEncoding("Qt%20is%20great%33");
      text.data();            // returns "Qt is great!"

See also:
  `toPercentEncoding()`, and `QUrl::fromPercentEncoding()`.

### number

    public static QByteArray number(double arg__1,
                                    byte f)

  Returns a byte array that contains the printed value of `n`, formatted in format `f` with precision `prec`.

  Argument `n` is formatted according to the `f` format specified, which is `g` by default, and can be any of the following:

  Format | Meaning
  --- | ---
  `e` | format as [-]9.9e[+|-]999
  `E` | format as [-]9.9E[+|-]999
  `f` | format as [-]9.9
  `g` | use `e` or `f` format, whichever is the most concise
  `G` | use `E` or `f` format, whichever is the most concise

  With 'e', 'E', and 'f', `prec` is the number of digits after the decimal point. With 'g' and 'G', `prec` is the maximum number of significant digits (trailing zeroes are omitted).

              QByteArray ba = QByteArray.number(12.3456, (byte)'E', 3);
              // ba == 1.235E+01

  Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.

See also:
  `toDouble()`.

### number

    public static QByteArray number(double arg__1)

  Returns a byte array that contains the printed value of `n`, formatted in format `f` with precision `prec`.

  Argument `n` is formatted according to the `f` format specified, which is `g` by default, and can be any of the following:

  Format | Meaning
  --- | ---
  `e` | format as [-]9.9e[+|-]999
  `E` | format as [-]9.9E[+|-]999
  `f` | format as [-]9.9
  `g` | use `e` or `f` format, whichever is the most concise
  `G` | use `E` or `f` format, whichever is the most concise

  With 'e', 'E', and 'f', `prec` is the number of digits after the decimal point. With 'g' and 'G', `prec` is the maximum number of significant digits (trailing zeroes are omitted).

              QByteArray ba = QByteArray.number(12.3456, (byte)'E', 3);
              // ba == 1.235E+01

  Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.

See also:
  `toDouble()`.

### number

    public static QByteArray number(double arg__1,
                                    byte f,
                                    int prec)

  Returns a byte array that contains the printed value of `n`, formatted in format `f` with precision `prec`.

  Argument `n` is formatted according to the `f` format specified, which is `g` by default, and can be any of the following:

  Format | Meaning
  --- | ---
  `e` | format as [-]9.9e[+|-]999
  `E` | format as [-]9.9E[+|-]999
  `f` | format as [-]9.9
  `g` | use `e` or `f` format, whichever is the most concise
  `G` | use `E` or `f` format, whichever is the most concise

  With 'e', 'E', and 'f', `prec` is the number of digits after the decimal point. With 'g' and 'G', `prec` is the maximum number of significant digits (trailing zeroes are omitted).

              QByteArray ba = QByteArray.number(12.3456, (byte)'E', 3);
              // ba == 1.235E+01

  Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.

See also:
  `toDouble()`.

### number

    public static QByteArray number(int arg__1)

  Returns a byte array containing the string equivalent of the number `n` to base `base` (10 by default). The `base` can be any value between 2 and 36.

  Example:

              int n = 63;
              QByteArray.number(n);              // returns "63"
              QByteArray.number(n, 16);          // returns "3f"
              QByteArray.number(n, 16).toUpper();  // returns "3F"

  Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.

See also:
  `setNum()`, and `toInt()`.

### number

    public static QByteArray number(int arg__1,
                                    int base)

  Returns a byte array containing the string equivalent of the number `n` to base `base` (10 by default). The `base` can be any value between 2 and 36.

  Example:

              int n = 63;
              QByteArray.number(n);              // returns "63"
              QByteArray.number(n, 16);          // returns "3f"
              QByteArray.number(n, 16).toUpper();  // returns "3F"

  Note: The format of the number is not localized; the default C locale is used irrespective of the user's locale.

See also:
  `setNum()`, and `toInt()`.

### number

    public static QByteArray number(long arg__1)

See also.
  toLongLong().

### number

    public static QByteArray number(long arg__1,
                                    int base)

  Returns a byte array containing the string equivalent of the number `arg__1` to base `base`. The `base` can be any value between 2 and 36.

  Example:

  ``

          int n = 63;
          QByteArray.number(n, 16);          // returns "3f"
          QByteArray.number(n, 16).upper();  // returns "3F"

### toString

    public java.lang.String toString()

  Returns a string representation of the `this QByteArray`.

  Overrides:
    `toString` in class `java.lang.Object`

### contains

    public final boolean contains(java.lang.String str)

  Returns true there is at least one occurrence of `str` in this QByteArray.

### count

    public final int count(java.lang.String str)

  Returns the number of occurrences of `str` in this QByteArray.

### endsWith

    public final boolean endsWith(java.lang.String str)

  Returns true if this QByteArray ends with `str`; otherwise, returns false.

### prepend

    public final QByteArray prepend(java.lang.String str)

  Prepends `str` to this QByteArray, and returns the resulting array.

### replace

    public final QByteArray replace(QByteArray before,
                                    java.lang.String after)

  Replaces every occurrence of the byte array `before` with the string `after`.

### replace

    public final QByteArray replace(java.lang.String before,
                                    java.lang.String after)

  Replaces every occurrence of `before` with `after`.

### startsWith

    public final boolean startsWith(java.lang.String str)

  Returns true if this byte array starts with string `str`; otherwise returns false.

### toByteArray

    public final byte[] toByteArray()

  Returns the contents of this QByteArray.

### set

    public final QByteArray set(QByteArray other)

  This function sets the contents of this QByteArray equal to `other`.

### toChar

    public final char toChar(int base)
                      throws java.lang.NumberFormatException

  Returns the byte array converted to an char using base `base`, which is 10 by default and must be between 2 and 36, or 0.

  Throws:
    `java.lang.NumberFormatException`

### toChar

    public char toChar()

  Returns the byte array converted to a char.

### toInt

    public final int toInt(int base)
                    throws java.lang.NumberFormatException

  Returns the byte array converted to an int using base `base`, which is 10 by default and must be between 2 and 36, or 0.

  If `base` is 0, the base is determined automatically using the following rules: If the byte array begins with "0x", it is assumed to be hexadecimal; if it begins with "0", it is assumed to be octal; otherwise it is assumed to be decimal.

  The function throws NumberFormatException if conversion fails.

  ``

          QByteArray str = new QByteArray("FF");
          int hex = str.toInt(16);     // hex == 255,
          int dec = str.toInt(10);     // throws NumberFormatException

  Throws:
    `java.lang.NumberFormatException`

### toInt

    public int toInt()

  Returns the byte array converted to an int using base 10.

### toDouble

    public final double toDouble()
                          throws java.lang.NumberFormatException

  Returns the byte array converted to an double.

  Throws:
    `java.lang.NumberFormatException`

### toFloat

    public final float toFloat()
                        throws java.lang.NumberFormatException

  Returns the byte array converted to an float.

  Throws:
    `java.lang.NumberFormatException`

### append

    public final QByteArray append(java.lang.String other)

  This function appends the contents of `other` to the end of this QByteArray.

### append

    public final QByteArray append(QByteArray other)

  This function appends the contents of `other` to the end of this QByteArray.

### append

    public final QByteArray append(byte other)

  This function appends `other` to the end of this QByteArray.

### fill

    public final QByteArray fill(byte b,
                                 int size)

  Sets every byte in the byte array to character `b`. If `size` is different from -1 (the default), the byte array is resized to size `size` beforehand.

  Example:

  ``

          QByteArray ba = new QByteArray("Istanbul");
          ba.fill("o");
          // ba == "oooooooo"

          ba.fill("X", 2);
          // ba == "XX"

### fill

    public QByteArray fill(byte b)

  Sets every byte in the byte array to character `b`.

### insert

    public final QByteArray insert(int i,
                                   QByteArray ba)

  Inserts the byte array `ba` at index position `i` and returns a reference to this byte array.

  Example:

  ``

          QByteArray ba = new QByteArray("Meal");
          ba.insert(1, QByteArray("ontr"));
          // ba == "Montreal"

### insert

    public final QByteArray insert(int i,
                                   byte b)

  Inserts byte `b` at index position `i` in the byte array. If `i` is greater than size(), the array is first extended using resize().

### insert

    public final QByteArray insert(int i,
                                   java.lang.String str)

  Inserts String `str` at index position `i` in the byte array. If `i` is greater than size(), the array is first extended using resize().

### prepend

    public final QByteArray prepend(QByteArray other)

  Prepends `other` to this QByteArray, and returns the resulting array.

### prepend

    public final QByteArray prepend(byte other)

  Prepends `other` to this QByteArray, and returns the resulting array.

### remove

    public final QByteArray remove(int pos,
                                   int len)

  Removes `len` bytes from the array, starting at index position `pos`, and returns a reference to the array.

  If `pos` is out of range, nothing happens. If `pos` is valid, but `pos` + `len` is larger than the size of the array, the array is truncated at position `pos`.

  Example:

  ``

          QByteArray ba = new QByteArray("Montreal");
          ba.remove(1, 4);
          // ba == "Meal"

### replace

    public final QByteArray replace(byte before,
                                    QByteArray after)

  Replaces every occurrence of `before` with `after`.

### replace

    public final QByteArray replace(int pos,
                                    int len,
                                    QByteArray after)

  Replaces every occurrence of `before` with `after`.

### replace

    public final QByteArray replace(byte before,
                                    java.lang.String after)

  Replaces every occurrence of `before` with `after`.

### replace

    public final QByteArray replace(byte before,
                                    byte after)

  Replaces every occurrence of `before` with `after`.

### replace

    public final QByteArray replace(QByteArray before,
                                    QByteArray after)

  Replaces every occurrence of `before` with `after`.

### replace

    public final QByteArray replace(java.lang.String before,
                                    QByteArray after)

  Replaces every occurrence of `before` with `after`.

### setNum

    public final QByteArray setNum(int n,
                                   int base)

  Sets the array to the printed value of `n` using `base` as base.

### setNum

    public QByteArray setNum(int n)

  Sets the array to the printed value of `n`

### setNum

    public final QByteArray setNum(char n,
                                   int base)

See also.
  toShort().

### setNum

    public QByteArray setNum(char n)

See also.
  toUShort().

### setNum

    public final QByteArray setNum(float n,
                                   char f,
                                   int prec)

  Sets the byte array to the printed value of `n`, formatted in format `f` with precision `prec`, and returns a reference to the byte array.

### setNum

    public final QByteArray setNum(float n,
                                   char f)

  Sets the byte array to the printed value of `n`, formatted in format `f` with precision 6, and returns a reference to the byte array.

### setNum

    public final QByteArray setNum(float n)

  Sets the byte array to the printed value of `n`, formatted in format `f` with precision 6, and returns a reference to the byte array.

### setNum

    public final QByteArray setNum(long n,
                                   int base)

  This is an overloaded function provided for convenience.

### setNum

    public QByteArray setNum(long n)

  This is an overloaded function provided for convenience.

### setNum

    public final QByteArray setNum(double n,
                                   char f,
                                   int prec)

  Sets the byte array to the printed value of `n`, formatted in format `f` with precision `prec`, and returns a reference to the byte array.

### setNum

    public final QByteArray setNum(double n,
                                   char f)

  This is an overloaded function provided for convenience.

### setNum

    public final QByteArray setNum(double n)

  This is an overloaded function provided for convenience.

### setNum

    public final QByteArray setNum(short n,
                                   int base)

  This is an overloaded function provided for convenience.

### setNum

    public QByteArray setNum(short n)

  This is an overloaded function provided for convenience.

### clone

    public QByteArray clone()

  This method is reimplemented for internal reasons

  Overrides:
    `clone` in class `java.lang.Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD