Class StringUtils

    • Constructor Summary

      Constructors 
      Constructor Description
      StringUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] getBytesIso8859_1​(String string)
      Encodes the given string into a sequence of bytes using the ISO-8859-1 charset, storing the result into a new byte array.
      static byte[] getBytesUnchecked​(String string, String charsetName)
      Encodes the given string into a sequence of bytes using the named charset, storing the result into a new byte array.
      static byte[] getBytesUsAscii​(String string)
      Encodes the given string into a sequence of bytes using the US-ASCII charset, storing the result into a new byte array.
      static byte[] getBytesUtf16​(String string)
      Encodes the given string into a sequence of bytes using the UTF-16 charset, storing the result into a new byte array.
      static byte[] getBytesUtf16Be​(String string)
      Encodes the given string into a sequence of bytes using the UTF-16BE charset, storing the result into a new byte array.
      static byte[] getBytesUtf16Le​(String string)
      Encodes the given string into a sequence of bytes using the UTF-16LE charset, storing the result into a new byte array.
      static byte[] getBytesUtf8​(String string)
      Encodes the given string into a sequence of bytes using the UTF-8 charset, storing the result into a new byte array.
      static String newString​(byte[] bytes, String charsetName)
      Constructs a new String by decoding the specified array of bytes using the given charset.
      static String newStringIso8859_1​(byte[] bytes)
      Constructs a new String by decoding the specified array of bytes using the ISO-8859-1 charset.
      static String newStringUsAscii​(byte[] bytes)
      Constructs a new String by decoding the specified array of bytes using the US-ASCII charset.
      static String newStringUtf16​(byte[] bytes)
      Constructs a new String by decoding the specified array of bytes using the UTF-16 charset.
      static String newStringUtf16Be​(byte[] bytes)
      Constructs a new String by decoding the specified array of bytes using the UTF-16BE charset.
      static String newStringUtf16Le​(byte[] bytes)
      Constructs a new String by decoding the specified array of bytes using the UTF-16LE charset.
      static String newStringUtf8​(byte[] bytes)
      Constructs a new String by decoding the specified array of bytes using the UTF-8 charset.
    • Method Detail

      • newStringIso8859_1

        public static String newStringIso8859_1​(byte[] bytes)
        Constructs a new String by decoding the specified array of bytes using the ISO-8859-1 charset.
        Parameters:
        bytes - The bytes to be decoded into characters
        Returns:
        A new String decoded from the specified array of bytes using the given charset.
        Throws:
        IllegalStateException - Thrown when a UnsupportedEncodingException is caught, which should never happen since the charset is required.
      • newStringUsAscii

        public static String newStringUsAscii​(byte[] bytes)
        Constructs a new String by decoding the specified array of bytes using the US-ASCII charset.
        Parameters:
        bytes - The bytes to be decoded into characters
        Returns:
        A new String decoded from the specified array of bytes using the given charset.
        Throws:
        IllegalStateException - Thrown when a UnsupportedEncodingException is caught, which should never happen since the charset is required.
      • newStringUtf16

        public static String newStringUtf16​(byte[] bytes)
        Constructs a new String by decoding the specified array of bytes using the UTF-16 charset.
        Parameters:
        bytes - The bytes to be decoded into characters
        Returns:
        A new String decoded from the specified array of bytes using the given charset.
        Throws:
        IllegalStateException - Thrown when a UnsupportedEncodingException is caught, which should never happen since the charset is required.
      • newStringUtf16Be

        public static String newStringUtf16Be​(byte[] bytes)
        Constructs a new String by decoding the specified array of bytes using the UTF-16BE charset.
        Parameters:
        bytes - The bytes to be decoded into characters
        Returns:
        A new String decoded from the specified array of bytes using the given charset.
        Throws:
        IllegalStateException - Thrown when a UnsupportedEncodingException is caught, which should never happen since the charset is required.
      • newStringUtf16Le

        public static String newStringUtf16Le​(byte[] bytes)
        Constructs a new String by decoding the specified array of bytes using the UTF-16LE charset.
        Parameters:
        bytes - The bytes to be decoded into characters
        Returns:
        A new String decoded from the specified array of bytes using the given charset.
        Throws:
        IllegalStateException - Thrown when a UnsupportedEncodingException is caught, which should never happen since the charset is required.
      • newStringUtf8

        public static String newStringUtf8​(byte[] bytes)
        Constructs a new String by decoding the specified array of bytes using the UTF-8 charset.
        Parameters:
        bytes - The bytes to be decoded into characters
        Returns:
        A new String decoded from the specified array of bytes using the given charset.
        Throws:
        IllegalStateException - Thrown when a UnsupportedEncodingException is caught, which should never happen since the charset is required.