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

StringencodeGoomojiSubject(String subject)
encode Goomoji Subject
final int maxlen = 75 - ("=?UTF-8?B?".length() + "?=".length());
StringBuilder sb = new StringBuilder();
int mark = 0;
int utf8len = "X-Goomoji-Subject: ".length();
for (int i = 0; i < subject.length();) {
    int cp = subject.codePointAt(i);
    int len;
    if (cp < 0x7f)
...
StringencodeHeaderValue(String headerName, String headerValue)
Encodes and folds the header value so it only contains ASCII characters (RFC 2047).
if (headerValue == null) {
    return null;
int nameLength = (headerName == null ? 0 : headerName.length());
return MimeUtility.fold(nameLength, MimeUtility.encodeText(headerValue));
StringencodeHTML(String input, boolean reduceToASCII, boolean useHTMLTags)
Encodes an input string of plain text to it's HTML representation.
return encodeHTML(input, reduceToASCII, (useHTMLTags ? LINEFEEDS_CONVERT_TO_BR : LINEFEEDS_REMOVE));
StringencodeHttpHeaderValueAsUTF8(String text)
encode Http Header Value As UTF
try {
    StringBuilder b = new StringBuilder();
    for (char c : text.toCharArray()) {
        if (0x20 <= c && c != '%' && c != '+' && c <= 0x7e) {
            b.append(c);
        } else {
            byte[] bytes = new String(new char[] { c }).getBytes("UTF-8");
            for (byte by : bytes) {
...
voidencodeImage(String sourceImagePath)
encode Image
File file = new File(sourceImagePath);
if (file.exists()) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    byte[] buffer = new byte[1024];
    int length = -1;
    InputStream is;
    try {
        is = new FileInputStream(file);
...
byte[]encodeInt(long value)
encode Int
byte[] tmp = new byte[4];
tmp[0] = (byte) ((value >>> 24) & 0xff);
tmp[1] = (byte) ((value >>> 16) & 0xff);
tmp[2] = (byte) ((value >>> 8) & 0xff);
tmp[3] = (byte) (value & 0xff);
return tmp;
StringencodeKeyForFileSystemName(String originalKey)
encode Key For File System Name
String encodedKey = originalKey.replace(keyChar, escapedKeyChar);
encodedKey = encodedKey.replace(File.separator, escapedSeparatorChar);
return encodedKey;
byte[]encodeObject(final Object object)
encode Object
final ByteArrayOutputStream byteStream = new ByteArrayOutputStream(2048);
final ObjectOutputStream stream = new ObjectOutputStream(new BufferedOutputStream(byteStream));
stream.writeObject(object);
stream.close();
byteStream.flush();
return byteStream.toByteArray();
byte[]encodeObject(Object obj)
encode Object
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = null;
try {
    oos = new ObjectOutputStream(baos);
    oos.writeObject(obj);
    return baos.toByteArray();
} catch (IOException e) {
    throw e;
...
voidencodeOID(byte[] in, OutputStream os)
encode OID
encodeBytes(OID, in, os);