Class EncodingUtil


  • public final class EncodingUtil
    extends java.lang.Object
    This file is a helper class for internal usage only. Be aware that its API and functionality may be changed in future.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String UTF8  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private EncodingUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] convertToBytes​(char[] chars, java.lang.String encoding)
      Converts to byte array an array of chars, taking the provided encoding into account.
      static java.lang.String convertToString​(byte[] bytes, java.lang.String encoding)
      Converts to String an array of bytes, taking the provided encoding into account.
      • Methods inherited from class java.lang.Object

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

      • EncodingUtil

        private EncodingUtil()
    • Method Detail

      • convertToBytes

        public static byte[] convertToBytes​(char[] chars,
                                            java.lang.String encoding)
                                     throws java.nio.charset.CharacterCodingException
        Converts to byte array an array of chars, taking the provided encoding into account.
        Parameters:
        chars - an array of chars to be converted to bytes
        encoding - the encoding to be taken into account while converting the provided array of chars
        Returns:
        the resultant array of bytes
        Throws:
        java.nio.charset.CharacterCodingException - if anything goes wrong while encoding
      • convertToString

        public static java.lang.String convertToString​(byte[] bytes,
                                                       java.lang.String encoding)
                                                throws java.io.UnsupportedEncodingException
        Converts to String an array of bytes, taking the provided encoding into account.
        Parameters:
        bytes - an array of bytes to be converted to String
        encoding - the encoding to be taken into account while converting the provided bytes
        Returns:
        the resultant string
        Throws:
        java.io.UnsupportedEncodingException - if anything goes wrong while encoding