Strings (Bouncy Castle Library 1.85 API Specification)
Date: 2026-07-12

org.bouncycastle.util

## Class Strings

- java.lang.Object
- - org.bouncycastle.util.Strings

-     public final class Strings
      extends java.lang.Object

  String utilities.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Strings()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static char[]` | `asCharArray(byte[] bytes)` Do a simple conversion of an array of 8 bit characters into a string.
    `static boolean` | `constantTimeAreEqual(java.lang.String a, java.lang.String b)` Constant time string comparison.
    `static java.lang.String` | `fromByteArray(byte[] bytes)` Convert an array of 8 bit characters into a string.
    `static java.lang.String` | `fromUTF8ByteArray(byte[] bytes)`
    `static java.lang.String` | `fromUTF8ByteArray(byte[] bytes, int off, int length)`
    `static java.lang.String` | `lineSeparator()`
    `static StringList` | `newList()`
    `static java.lang.String[]` | `split(java.lang.String input, char delimiter)`
    `static byte[]` | `toByteArray(char[] chars)`
    `static byte[]` | `toByteArray(java.lang.String string)`
    `static int` | `toByteArray(java.lang.String s, byte[] buf, int off)`
    `static java.lang.String` | `toLowerCase(java.lang.String string)` A locale independent version of toLowerCase.
    `static java.lang.String` | `toUpperCase(java.lang.String string)` A locale independent version of toUpperCase.
    `static byte[]` | `toUTF8ByteArray(char[] string)`
    `static byte[]` | `toUTF8ByteArray(char[] cs, int csOff, int csLen)`
    `static void` | `toUTF8ByteArray(char[] cs, int csOff, int csLen, java.io.OutputStream sOut)`
    `static void` | `toUTF8ByteArray(char[] string, java.io.OutputStream sOut)`
    `static byte[]` | `toUTF8ByteArray(java.lang.String string)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Strings

          public Strings()

  - ### Method Detail

    - #### fromUTF8ByteArray

          public static java.lang.String fromUTF8ByteArray(byte[] bytes)

    - #### fromUTF8ByteArray

          public static java.lang.String fromUTF8ByteArray(byte[] bytes,
                                                           int off,
                                                           int length)

    - #### toUTF8ByteArray

          public static byte[] toUTF8ByteArray(java.lang.String string)

    - #### toUTF8ByteArray

          public static byte[] toUTF8ByteArray(char[] string)

    - #### toUTF8ByteArray

          public static byte[] toUTF8ByteArray(char[] cs,
                                               int csOff,
                                               int csLen)

    - #### toUTF8ByteArray

          public static void toUTF8ByteArray(char[] string,
                                             java.io.OutputStream sOut)
                                      throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### toUTF8ByteArray

          public static void toUTF8ByteArray(char[] cs,
                                             int csOff,
                                             int csLen,
                                             java.io.OutputStream sOut)
                                      throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### toUpperCase

          public static java.lang.String toUpperCase(java.lang.String string)

      A locale independent version of toUpperCase.
      Parameters:
        `string` - input to be converted
      Returns:
        a US Ascii uppercase version

    - #### toLowerCase

          public static java.lang.String toLowerCase(java.lang.String string)

      A locale independent version of toLowerCase.
      Parameters:
        `string` - input to be converted
      Returns:
        a US ASCII lowercase version

    - #### toByteArray

          public static byte[] toByteArray(char[] chars)

    - #### toByteArray

          public static byte[] toByteArray(java.lang.String string)

    - #### toByteArray

          public static int toByteArray(java.lang.String s,
                                        byte[] buf,
                                        int off)

    - #### constantTimeAreEqual

          public static boolean constantTimeAreEqual(java.lang.String a,
                                                     java.lang.String b)

      Constant time string comparison.
      Parameters:
        `a` - a string.
        `b` - another string to compare to a.
      Returns:
        true if a and b represent the same string, false otherwise.

    - #### fromByteArray

          public static java.lang.String fromByteArray(byte[] bytes)

      Convert an array of 8 bit characters into a string.
      Parameters:
        `bytes` - 8 bit characters.
      Returns:
        resulting String.

    - #### asCharArray

          public static char[] asCharArray(byte[] bytes)

      Do a simple conversion of an array of 8 bit characters into a string.
      Parameters:
        `bytes` - 8 bit characters.
      Returns:
        resulting String.

    - #### split

          public static java.lang.String[] split(java.lang.String input,
                                                 char delimiter)

    - #### newList

          public static StringList newList()

    - #### lineSeparator

          public static java.lang.String lineSeparator()