B4A Library [B4X] BytesBuilder - simplifies working with arrays of bytes

Discussion in 'Additional libraries, classes and official updates' started by Erel, Jan 31, 2018.

  1. Erel

    Erel Administrator Staff Member Licensed User

    Edit: BytesBuilder is included in B4XCollections library (named B4XBytesBuilder).

    BytesBuilder class, which is compatible with B4A, B4i and B4J, makes it easier to work with bytes.
    You can think of it as a combination of String and StringBuilder, but instead of holding characters it holds bytes.

    Modifying the stored data is done with:
    • Append - Adds data at the end.
    • Insert - Inserts data at the given index.
    • Set - Replaces data starting from the given index
    • Remove - Removes the data in the given range.
    • Clear - Clears the data.
    Note that the internal buffer grows automatically as needed.

    Reading the data is done with:
    • SubArray / SubArray2 - Similar to String.SubString
    • ToArray - Similar to StringBuilder.ToString. Returns a complete copy of the data.
    • IndexOf / IndexOf2 - Similar to String.IndexOf

    B4A, B4J - ByteConverter
    B4i - iRandomAccessFile

    Dim bb As BytesBuilder
    For i = 0 To 255
    Array As Byte(i))
    1Array As Byte(0xFF0XFF0xFF))
    Log(bb.IndexOf(Array As Byte(101112)))
    Log(bb.IndexOf(Array As Byte(0)))
    Log(bb.IndexOf2(Array As Byte(0xFF), 3))
    Dim bc As ByteConverter
    Last edited: Oct 13, 2019
  2. Beja

    Beja Expert Licensed User

    Wow! That's the class b4x was missing.
    Thanks Erel .. You don't stop surprising us with new useful tools .all thumps up!
    DonManfred likes this.
  3. naifnas

    naifnas Active Member Licensed User

    your alloys this first
  4. victormedranop

    victormedranop Well-Known Member Licensed User

    Just when I finished this APS.

  5. warwound

    warwound Expert Licensed User

    naifnas likes this.
  6. Erel

    Erel Administrator Staff Member Licensed User

    It is not available online. You can see the methods description in the IDE itself.
    The methods should be straightforward. If you have any question then please post it.
    warwound likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice