Interface ByteUtils


public interface ByteUtils
This interface gives you access to various methods for querying and manipulating byte arrays.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    This method can be used to convert data from String form into an array of bytes.
    convertToString(byte[] bytes)
    This method can be used to convert data from an array of bytes into String form.
    int
    countMatches(byte[] data, byte[] searchTerm)
    This method searches a piece of data and counts all matches for a specified pattern.
    int
    countMatches(byte[] data, byte[] searchTerm, boolean caseSensitive)
    This method searches a piece of data and counts all matches for a specified pattern.
    int
    countMatches(byte[] data, byte[] searchTerm, boolean caseSensitive, int from, int to)
    This method searches a piece of data and counts all matches for a specified pattern.
    int
    countMatches(byte[] data, Pattern pattern)
    This method searches a piece of data and counts all matches for a specified pattern.
    int
    countMatches(byte[] data, Pattern pattern, int from, int to)
    This method searches a piece of data and counts all matches for a specified pattern.
    int
    indexOf(byte[] data, byte[] searchTerm)
    This method searches a piece of data for the first occurrence of a specified pattern.
    int
    indexOf(byte[] data, byte[] searchTerm, boolean caseSensitive)
    This method searches a piece of data for the first occurrence of a specified pattern.
    int
    indexOf(byte[] data, byte[] searchTerm, boolean caseSensitive, int from, int to)
    This method searches a piece of data for the first occurrence of a specified pattern.
    int
    indexOf(byte[] data, Pattern pattern)
    This method searches a piece of data for the first occurrence of a specified pattern.
    int
    indexOf(byte[] data, Pattern pattern, int from, int to)
    This method searches a piece of data for the first occurrence of a specified pattern.
  • Method Details

    • indexOf

      int indexOf(byte[] data, byte[] searchTerm)
      This method searches a piece of data for the first occurrence of a specified pattern. 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:
      data - The data to be searched.
      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(byte[] data, byte[] searchTerm, boolean caseSensitive)
      This method searches a piece of data for the first occurrence of a specified pattern. 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:
      data - The data to be searched.
      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(byte[] data, byte[] searchTerm, boolean caseSensitive, int from, int to)
      This method searches a piece of data for the first occurrence of a specified pattern. 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:
      data - The data to be searched.
      searchTerm - The value to be searched for.
      caseSensitive - Flags whether the search is case-sensitive.
      from - The offset within data where the search should begin.
      to - The offset within data where the search should end.
      Returns:
      The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
    • indexOf

      int indexOf(byte[] data, Pattern pattern)
      This method searches a piece of data for the first occurrence of a specified pattern.
      Parameters:
      data - The data to be searched.
      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(byte[] data, Pattern pattern, int from, int to)
      This method searches a piece of data for the first occurrence of a specified pattern.
      Parameters:
      data - The data to be searched.
      pattern - The pattern to be matched.
      from - The offset within data where the search should begin.
      to - The offset within data where the search should end.
      Returns:
      The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
    • countMatches

      int countMatches(byte[] data, byte[] searchTerm)
      This method searches a piece of data and counts all matches for a specified pattern.
      Parameters:
      data - The data to be searched.
      searchTerm - The value to be searched for.
      Returns:
      The count of all matches of the pattern.
    • countMatches

      int countMatches(byte[] data, byte[] searchTerm, boolean caseSensitive)
      This method searches a piece of data and counts all matches for a specified pattern.
      Parameters:
      data - The data to be searched.
      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(byte[] data, byte[] searchTerm, boolean caseSensitive, int from, int to)
      This method searches a piece of data and counts all matches for a specified pattern.
      Parameters:
      data - The data to be searched.
      searchTerm - The value to be searched for.
      caseSensitive - Flags whether the search is case-sensitive.
      from - The offset within data where the search should begin.
      to - The offset within data where the search should end.
      Returns:
      The count of all matches of the pattern within the specified bounds.
    • countMatches

      int countMatches(byte[] data, Pattern pattern)
      This method searches a piece of data and counts all matches for a specified pattern.
      Parameters:
      data - The data to be searched.
      pattern - The pattern to be matched.
      Returns:
      The count of all matches of the pattern within the specified bounds.
    • countMatches

      int countMatches(byte[] data, Pattern pattern, int from, int to)
      This method searches a piece of data and counts all matches for a specified pattern.
      Parameters:
      data - The data to be searched.
      pattern - The pattern to be matched.
      from - The offset within data where the search should begin.
      to - The offset within data where the search should end.
      Returns:
      The count of all matches of the pattern within the specified bounds.
    • convertToString

      String convertToString(byte[] bytes)
      This method can be used to convert data from an array of bytes into String form. The conversion does not reflect any particular character set, and a byte with the representation 0xYZ will always be converted into a character with the hex representation 0x00YZ. It performs the opposite conversion to the method convertFromString(String), and byte-based data that is converted to a String and back again using these two methods is guaranteed to retain its integrity (which may not be the case with conversions that reflect a given character set).
      Parameters:
      bytes - The data to be converted.
      Returns:
      The converted data.
    • convertFromString

      byte[] convertFromString(String string)
      This method can be used to convert data from String form into an array of bytes. The conversion does not reflect any particular character set, and a character with the hex representation 0xWXYZ will always be converted into a byte with the representation 0xYZ. It performs the opposite conversion to the method convertToString(byte[]), and byte-based data that is converted to a String and back again using these two methods is guaranteed to retain its integrity (which may not be the case with conversions that reflect a given character set).
      Parameters:
      string - The data to be converted
      Returns:
      The converted data.