Java Utililty Methods Encode

List of utility methods to do Encode

Description

The list of methods to do Encode are organized into topic(s).

Method

StringencodeParameter(String name, String value, String encoding, String lang)
encode Parameter
StringBuffer result = new StringBuffer();
StringBuffer encodedPart = new StringBuffer();
boolean needWriteCES = !isAllAscii(value);
boolean CESWasWritten = false;
boolean encoded;
boolean needFolding = false;
int sequenceNo = 0;
int column;
...
StringencodePart(final String part, final String charset, final BitSet allowed)
Encodes a string to be a valid URI part, with the given characters allowed.
if (part == null) {
    return null;
final StringBuffer encoded = new StringBuffer(part.length() * 3);
final char[] toEncode = part.toCharArray();
for (final char c : toEncode) {
    if (allowed.get(c)) {
        encoded.append(c);
...
InternetAddress[]encodePersonal(InternetAddress[] addresses)
encode Personal
if (addresses == null) {
    return null;
for (InternetAddress address : addresses) {
    if (address.getPersonal() != null) {
        address.setPersonal(address.getPersonal(), "UTF-8");
return addresses;
StringencodeQP(String text)
encode QP
try {
    byte[] utf8 = text.getBytes("UTF-8");
    StringBuilder sb = new StringBuilder();
    int column = 0;
    for (int i = 0; i < utf8.length; i++) {
        char ch = (char) utf8[i];
        if (ch == '\n') {
            sb.append(ch);
...
StringencodeResult(final Object result)
encode Result
return doEncode((Serializable) result);
voidencodeRGBAsGrayScale(final byte[] raw, final int width, final int height, final int bitsPerPixel, final OutputStream out)
Converts a byte array containing 24 bit RGB image data to a grayscale image.
final int pixelsPerByte = 8 / bitsPerPixel;
int bytewidth = width / pixelsPerByte;
if (width % pixelsPerByte != 0) {
    bytewidth++;
final byte[] linedata = new byte[bytewidth];
byte ib;
for (int y = 0; y < height; y++) {
...
StringencodeStringBase64(String str)

Encodes a given string to Base64.

if (isEmptyString(str)) {
    return str;
final String c = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
byte[] code = c.getBytes();
byte[] s = str.getBytes();
int x;
int y = str.length() - (str.length() % 3);
...
voidencodeTagChar(char c, Appendable buffer)
encode a char in TSDB format and append it to a buffer
String hex = Integer.toHexString(c);
buffer.append('-');
for (int len = hex.length(); len < 4; len++) {
    buffer.append('0');
buffer.append(hex);
StringencodeToTargetEncoding(String text, String sourceEncoding, String targetEncoding)
encode To Target Encoding
String ret = new String(text.getBytes(sourceEncoding), targetEncoding);
return ret;
booleanencodeUint(OutputStream out, final long value)
Unsigned integers are the basis for all other primitive values.
if ((value & 0x7f) == value) {
    out.write((byte) value);
    return value != 0;
int len = 0;
while (((value >>> (len * 8)) | 0xff) != 0xff) {
    len++;
len++;
out.write(-len);
while (len > 0) {
    len--;
    out.write((byte) (value >>> (len * 8)));
return true;