Java Base64 base64Pad(String s)

Here you can find the source of base64Pad(String s)

Description

Pads a given String s to be usable for BASE64Decoder (if it isn't padded the resulting deoceded data may be wrong)

License

Apache License

Parameter

Parameter Description
s a parameter

Declaration

public static String base64Pad(String s) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//from   ww w.j av  a 2  s.  com
     * Pads a given String s to be usable for BASE64Decoder (if it isn't padded the resulting deoceded data may be wrong)
     * @param s
     * @return
     */
    public static String base64Pad(String s) {
        int toPad = s.length() % 4;
        for (int i = 0; i < toPad; ++i) {
            s = s + "=";
        }

        return s;
    }
}

Related

  1. base64Append(StringBuilder sb, int digit, boolean haveNonZero)
  2. base64Append(StringBuilder sb, int digit, boolean haveNonZero)
  3. base64Character(int number)
  4. base64CharToValue(byte c)
  5. base64enc(byte[] in)
  6. base64ReadChunk(InputStream in, byte[] chunk)
  7. base64ToBits(char data)
  8. base64ToByteArray(String s)
  9. base64ToBytes(final String base64)