Java Base64 base64Append(StringBuilder sb, int digit, boolean haveNonZero)

Here you can find the source of base64Append(StringBuilder sb, int digit, boolean haveNonZero)

Description

base Append

License

Apache License

Declaration

private static boolean base64Append(StringBuilder sb, int digit, boolean haveNonZero) 

Method Source Code

//package com.java2s;
/*//from  ww w  . j  a va 2 s.  c o  m
 * Copyright 2009 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

public class Main {
    /**
     * An array mapping size but values to the characters that will be used to
     * represent them. Note that this is not identical to the set of characters
     * used by MIME-Base64.
     */
    private static final char[] base64Chars = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
            'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
            'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0',
            '1', '2', '3', '4', '5', '6', '7', '8', '9', '$', '_' };

    private static boolean base64Append(StringBuilder sb, int digit, boolean haveNonZero) {
        if (digit > 0) {
            haveNonZero = true;
        }
        if (haveNonZero) {
            sb.append(base64Chars[digit]);
        }
        return haveNonZero;
    }
}

Related

  1. base64(byte[] raw)
  2. base64(final byte[] stringArray)
  3. Base64(String msg)
  4. base64(String string)
  5. base64(String value)
  6. base64Append(StringBuilder sb, int digit, boolean haveNonZero)
  7. base64Character(int number)
  8. base64CharToValue(byte c)
  9. base64enc(byte[] in)