Interface ByteArray

All Superinterfaces:
Iterable<Byte>

public interface ByteArray extends Iterable<Byte>
Burp ByteArray with various methods for querying and manipulating byte arrays.
  • Method Summary

    Modifier and Type
    Method
    Description
    static ByteArray
    byteArray(byte... data)
    Create a new ByteArray with the provided byte data.
    static ByteArray
    byteArray(int... data)
    Create a new ByteArray with the provided integers after a narrowing primitive conversion to bytes.
    static ByteArray
    Create a new ByteArray from the provided text using the encoding specified by Burp Suite.
    static ByteArray
    byteArrayOfLength(int length)
    Create a new ByteArray with the provided length.
    Create a copy of the ByteArray
    Create a copy of the ByteArray in temporary file.
    This method is used to save the ByteArray object to a temporary file, so that it is no longer held in memory.
    int
    countMatches(ByteArray searchTerm)
    Searches the data in the ByteArray and counts all matches for a specified term.
    int
    countMatches(ByteArray searchTerm, boolean caseSensitive)
    Searches the data in the ByteArray and counts all matches for a specified term.
    int
    countMatches(ByteArray searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive)
    Searches the data in the ByteArray and counts all matches for a specified term.
    int
    countMatches(String searchTerm)
    Searches the data in the ByteArray and counts all matches for a specified term.
    int
    countMatches(String searchTerm, boolean caseSensitive)
    Searches the data in the ByteArray and counts all matches for a specified term.
    int
    countMatches(String searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive)
    Searches the data in the ByteArray and counts all matches for a specified term.
    int
    Searches the data in the ByteArray and counts all matches for a specified pattern.
    int
    countMatches(Pattern pattern, int startIndexInclusive, int endIndexExclusive)
    Searches the data in the ByteArray and counts all matches for a specified pattern.
    byte
    getByte(int index)
    Access the byte stored at the provided index.
    byte[]
    Copy of all bytes
    int
    indexOf(ByteArray searchTerm)
    Searches the data in the ByteArray for the first occurrence of a specified term.
    int
    indexOf(ByteArray searchTerm, boolean caseSensitive)
    Searches the data in the ByteArray for the first occurrence of a specified term.
    int
    indexOf(ByteArray searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive)
    Searches the data in the ByteArray for the first occurrence of a specified term.
    int
    indexOf(String searchTerm)
    Searches the data in the ByteArray for the first occurrence of a specified term.
    int
    indexOf(String searchTerm, boolean caseSensitive)
    Searches the data in the ByteArray for the first occurrence of a specified term.
    int
    indexOf(String searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive)
    Searches the data in the ByteArray for the first occurrence of a specified term.
    int
    indexOf(Pattern pattern)
    Searches the data in the ByteArray for the first occurrence of a specified pattern.
    int
    indexOf(Pattern pattern, int startIndexInclusive, int endIndexExclusive)
    Searches the data in the ByteArray for the first occurrence of a specified pattern.
    int
    Number of bytes stored in the ByteArray.
    void
    setByte(int index, byte value)
    Sets the byte at the provided index to the provided byte.
    void
    setByte(int index, int value)
    Sets the byte at the provided index to the provided narrowed integer value.
    void
    setBytes(int index, byte... data)
    Sets bytes starting at the specified index to the provided bytes.
    void
    setBytes(int index, int... data)
    Sets bytes starting at the specified index to the provided integers after narrowing primitive conversion to bytes.
    void
    setBytes(int index, ByteArray byteArray)
    Sets bytes starting at the specified index to the provided bytes.
    subArray(int startIndexInclusive, int endIndexExclusive)
    New ByteArray with all bytes between the start index (inclusive) and the end index (exclusive).
    subArray(Range range)
    New ByteArray with all bytes in the specified range.
    Convert the bytes of the ByteArray into String form using the encoding specified by Burp Suite.
    withAppended(byte... data)
    Create a copy of the ByteArray appended with the provided bytes.
    withAppended(int... data)
    Create a copy of the ByteArray appended with the provided integers after narrowing primitive conversion to bytes.
    Create a copy of the ByteArray appended with the provided ByteArray.
    Create a copy of the ByteArray appended with the provided text as bytes.

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator
  • Method Details

    • getByte

      byte getByte(int index)
      Access the byte stored at the provided index.
      Parameters:
      index - Index of the byte to be retrieved.
      Returns:
      The byte at the index.
    • setByte

      void setByte(int index, byte value)
      Sets the byte at the provided index to the provided byte.
      Parameters:
      index - Index of the byte to be set.
      value - The byte to be set.
    • setByte

      void setByte(int index, int value)
      Sets the byte at the provided index to the provided narrowed integer value.
      Parameters:
      index - Index of the byte to be set.
      value - The integer value to be set after a narrowing primitive conversion to a byte.
    • setBytes

      void setBytes(int index, byte... data)
      Sets bytes starting at the specified index to the provided bytes.
      Parameters:
      index - The index of the first byte to set.
      data - The byte[] or sequence of bytes to be set.
    • setBytes

      void setBytes(int index, int... data)
      Sets bytes starting at the specified index to the provided integers after narrowing primitive conversion to bytes.
      Parameters:
      index - The index of the first byte to set.
      data - The int[] or the sequence of integers to be set after a narrowing primitive conversion to bytes.
    • setBytes

      void setBytes(int index, ByteArray byteArray)
      Sets bytes starting at the specified index to the provided bytes.
      Parameters:
      index - The index of the first byte to set.
      byteArray - The ByteArray object holding the provided bytes.
    • length

      int length()
      Number of bytes stored in the ByteArray.
      Returns:
      Length of the ByteArray.
    • getBytes

      byte[] getBytes()
      Copy of all bytes
      Returns:
      Copy of all bytes.
    • subArray

      ByteArray subArray(int startIndexInclusive, int endIndexExclusive)
      New ByteArray with all bytes between the start index (inclusive) and the end index (exclusive).
      Parameters:
      startIndexInclusive - The inclusive start index of retrieved range.
      endIndexExclusive - The exclusive end index of retrieved range.
      Returns:
      ByteArray containing all bytes in the specified range.
    • subArray

      ByteArray subArray(Range range)
      New ByteArray with all bytes in the specified range.
      Parameters:
      range - The Range of bytes to be returned.
      Returns:
      ByteArray containing all bytes in the specified range.
    • copy

      ByteArray copy()
      Create a copy of the ByteArray
      Returns:
      New ByteArray with a copy of the wrapped bytes.
    • copyToTempFile

      ByteArray copyToTempFile()
      Create a copy of the ByteArray in temporary file.
      This method is used to save the ByteArray object to a temporary file, so that it is no longer held in memory. Extensions can use this method to convert ByteArray objects into a form suitable for long-term usage.
      Returns:
      A new ByteArray instance stored in temporary file.
    • indexOf

      int indexOf(ByteArray searchTerm)
      Searches the data in the ByteArray for the first occurrence of a specified term. It works on byte-based data in a way that is similar to the way the native Java method String.indexOf(String) works on String-based data.
      Parameters:
      searchTerm - The value to be searched for.
      Returns:
      The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
    • indexOf

      int indexOf(String searchTerm)
      Searches the data in the ByteArray for the first occurrence of a specified term. It works on byte-based data in a way that is similar to the way the native Java method String.indexOf(String) works on String-based data.
      Parameters:
      searchTerm - The value to be searched for.
      Returns:
      The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
    • indexOf

      int indexOf(ByteArray searchTerm, boolean caseSensitive)
      Searches the data in the ByteArray for the first occurrence of a specified term. It works on byte-based data in a way that is similar to the way the native Java method String.indexOf(String) works on String-based data.
      Parameters:
      searchTerm - The value to be searched for.
      caseSensitive - Flags whether the search is case-sensitive.
      Returns:
      The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
    • indexOf

      int indexOf(String searchTerm, boolean caseSensitive)
      Searches the data in the ByteArray for the first occurrence of a specified term. It works on byte-based data in a way that is similar to the way the native Java method String.indexOf(String) works on String-based data.
      Parameters:
      searchTerm - The value to be searched for.
      caseSensitive - Flags whether the search is case-sensitive.
      Returns:
      The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
    • indexOf

      int indexOf(ByteArray searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive)
      Searches the data in the ByteArray for the first occurrence of a specified term. It works on byte-based data in a way that is similar to the way the native Java method String.indexOf(String) works on String-based data.
      Parameters:
      searchTerm - The value to be searched for.
      caseSensitive - Flags whether the search is case-sensitive.
      startIndexInclusive - The inclusive start index for the search.
      endIndexExclusive - The exclusive end index for the search.
      Returns:
      The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
    • indexOf

      int indexOf(String searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive)
      Searches the data in the ByteArray for the first occurrence of a specified term. It works on byte-based data in a way that is similar to the way the native Java method String.indexOf(String) works on String-based data.
      Parameters:
      searchTerm - The value to be searched for.
      caseSensitive - Flags whether the search is case-sensitive.
      startIndexInclusive - The inclusive start index for the search.
      endIndexExclusive - The exclusive end index for the search.
      Returns:
      The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
    • indexOf

      int indexOf(Pattern pattern)
      Searches the data in the ByteArray for the first occurrence of a specified pattern.
      Parameters:
      pattern - The pattern to be matched.
      Returns:
      The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
    • indexOf

      int indexOf(Pattern pattern, int startIndexInclusive, int endIndexExclusive)
      Searches the data in the ByteArray for the first occurrence of a specified pattern.
      Parameters:
      pattern - The pattern to be matched.
      startIndexInclusive - The inclusive start index for the search.
      endIndexExclusive - The exclusive end index for the search.
      Returns:
      The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
    • countMatches

      int countMatches(ByteArray searchTerm)
      Searches the data in the ByteArray and counts all matches for a specified term.
      Parameters:
      searchTerm - The value to be searched for.
      Returns:
      The count of all matches of the pattern.
    • countMatches

      int countMatches(String searchTerm)
      Searches the data in the ByteArray and counts all matches for a specified term.
      Parameters:
      searchTerm - The value to be searched for.
      Returns:
      The count of all matches of the pattern.
    • countMatches

      int countMatches(ByteArray searchTerm, boolean caseSensitive)
      Searches the data in the ByteArray and counts all matches for a specified term.
      Parameters:
      searchTerm - The value to be searched for.
      caseSensitive - Flags whether the search is case-sensitive.
      Returns:
      The count of all matches of the pattern.
    • countMatches

      int countMatches(String searchTerm, boolean caseSensitive)
      Searches the data in the ByteArray and counts all matches for a specified term.
      Parameters:
      searchTerm - The value to be searched for.
      caseSensitive - Flags whether the search is case-sensitive.
      Returns:
      The count of all matches of the pattern.
    • countMatches

      int countMatches(ByteArray searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive)
      Searches the data in the ByteArray and counts all matches for a specified term.
      Parameters:
      searchTerm - The value to be searched for.
      caseSensitive - Flags whether the search is case-sensitive.
      startIndexInclusive - The inclusive start index for the search.
      endIndexExclusive - The exclusive end index for the search.
      Returns:
      The count of all matches of the pattern within the specified bounds.
    • countMatches

      int countMatches(String searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive)
      Searches the data in the ByteArray and counts all matches for a specified term.
      Parameters:
      searchTerm - The value to be searched for.
      caseSensitive - Flags whether the search is case-sensitive.
      startIndexInclusive - The inclusive start index for the search.
      endIndexExclusive - The exclusive end index for the search.
      Returns:
      The count of all matches of the pattern within the specified bounds.
    • countMatches

      int countMatches(Pattern pattern)
      Searches the data in the ByteArray and counts all matches for a specified pattern.
      Parameters:
      pattern - The pattern to be matched.
      Returns:
      The count of all matches of the pattern within the specified bounds.
    • countMatches

      int countMatches(Pattern pattern, int startIndexInclusive, int endIndexExclusive)
      Searches the data in the ByteArray and counts all matches for a specified pattern.
      Parameters:
      pattern - The pattern to be matched.
      startIndexInclusive - The inclusive start index for the search.
      endIndexExclusive - The exclusive end index for the search.
      Returns:
      The count of all matches of the pattern within the specified bounds.
    • toString

      String toString()
      Convert the bytes of the ByteArray into String form using the encoding specified by Burp Suite.
      Overrides:
      toString in class Object
      Returns:
      The converted data in String form.
    • withAppended

      ByteArray withAppended(byte... data)
      Create a copy of the ByteArray appended with the provided bytes.
      Parameters:
      data - The byte[] or sequence of bytes to append.
    • withAppended

      ByteArray withAppended(int... data)
      Create a copy of the ByteArray appended with the provided integers after narrowing primitive conversion to bytes.
      Parameters:
      data - The int[] or sequence of integers to append after narrowing primitive conversion to bytes.
    • withAppended

      ByteArray withAppended(String text)
      Create a copy of the ByteArray appended with the provided text as bytes.
      Parameters:
      text - The string to append.
    • withAppended

      ByteArray withAppended(ByteArray byteArray)
      Create a copy of the ByteArray appended with the provided ByteArray.
      Parameters:
      byteArray - The ByteArray to append.
    • byteArrayOfLength

      static ByteArray byteArrayOfLength(int length)
      Create a new ByteArray with the provided length.
      Parameters:
      length - array length.
      Returns:
      New ByteArray with the provided length.
    • byteArray

      static ByteArray byteArray(byte... data)
      Create a new ByteArray with the provided byte data.
      Parameters:
      data - byte[] to wrap, or sequence of bytes to wrap.
      Returns:
      New ByteArray wrapping the provided byte array.
    • byteArray

      static ByteArray byteArray(int... data)
      Create a new ByteArray with the provided integers after a narrowing primitive conversion to bytes.
      Parameters:
      data - int[] to wrap or sequence of integers to wrap.
      Returns:
      New ByteArray wrapping the provided data after a narrowing primitive conversion to bytes.
    • byteArray

      static ByteArray byteArray(String text)
      Create a new ByteArray from the provided text using the encoding specified by Burp Suite.
      Parameters:
      text - the text for the byte array.
      Returns:
      New ByteArray holding a copy of the text as bytes.