Package com.itextpdf.commons.utils
Class EncodingUtil
java.lang.Object
com.itextpdf.commons.utils.EncodingUtil
This file is a helper class for internal usage only. Be aware that its API and functionality may be changed in future.
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]convertToBytes(char[] chars, String encoding) Converts to byte array an array of chars, taking the provided encoding into account.static StringconvertToString(byte[] bytes, String encoding) Converts to String an array of bytes, taking the provided encoding into account.static byte[]fromBase64(String base64) Decodes base64 string into byte array with tolerance to new lines and spaces.static StringtoBase64(byte[] bytes) Encodes byte array to base64 string.
-
Method Details
-
convertToBytes
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:
-
CharacterCodingException- if anything goes wrong while encoding
-
convertToString
public static String convertToString(byte[] bytes, String encoding) throws 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:
-
UnsupportedEncodingException- if anything goes wrong while encoding
-
fromBase64
Decodes base64 string into byte array with tolerance to new lines and spaces.- Parameters:
-
base64- base64 string to decode - Returns:
- decode string as byte array
-
toBase64
Encodes byte array to base64 string.- Parameters:
-
bytes- the byte array to encode - Returns:
- encoded base64 string
-