Class TextUtils


  • public final class TextUtils
    extends java.lang.Object
    Utility methods relating to text.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] stringToByteArray​(java.lang.String content, java.nio.charset.Charset charset)
      Converts a string into a byte array using the specified encoding.
      static java.io.InputStream toInputStream​(java.lang.String content)
      Convert a string into an input stream.
      static java.io.InputStream toInputStream​(java.lang.String content, java.nio.charset.Charset charset)
      Convert a string into an input stream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • toInputStream

        public static java.io.InputStream toInputStream​(java.lang.String content)
        Convert a string into an input stream.
        Parameters:
        content - the string
        Returns:
        the resulting input stream
      • toInputStream

        public static java.io.InputStream toInputStream​(java.lang.String content,
                                                        java.nio.charset.Charset charset)
        Convert a string into an input stream.
        Parameters:
        content - the string
        charset - the encoding to use when converting the string to a stream
        Returns:
        the resulting input stream
      • stringToByteArray

        public static byte[] stringToByteArray​(java.lang.String content,
                                               java.nio.charset.Charset charset)
        Converts a string into a byte array using the specified encoding.
        Parameters:
        charset - the charset
        content - the string to convert
        Returns:
        the String as a byte[]; if the specified encoding is not supported an empty byte[] will be returned