Android Hex String Create appendHex(final StringBuffer buf, final int i)

Here you can find the source of appendHex(final StringBuffer buf, final int i)

Description

append Hex

License

Apache License

Declaration

public static void appendHex(final StringBuffer buf, final int i) 

Method Source Code

//package com.java2s;
/*/*from   www.  j a  va 2s .  co  m*/
 * Copyright 2004-2011 the Seasar Foundation and the Others.
 *
 * 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 {

    public static void appendHex(final StringBuffer buf, final byte i) {
        buf.append(Character.forDigit((i & 0xf0) >> 4, 16));
        buf.append(Character.forDigit((i & 0x0f), 16));
    }

    public static void appendHex(final StringBuffer buf, final int i) {
        buf.append(Integer.toHexString((i >> 24) & 0xff));
        buf.append(Integer.toHexString((i >> 16) & 0xff));
        buf.append(Integer.toHexString((i >> 8) & 0xff));
        buf.append(Integer.toHexString(i & 0xff));
    }
}

Related

  1. isHexChar(char ch)
  2. isHexChar(String hexString, boolean checkSpaceFlag)
  3. isHexChar(String hexString)
  4. toHexChar(int nibble)
  5. appendHex(final StringBuffer buf, final byte i)
  6. toHex(final int i)
  7. appendHexJavaScriptRepresentation(int codePoint, Appendable out)
  8. appendHexJavaScriptRepresentation(StringBuilder sb, char c)
  9. bytesToHexString(byte[] bArray)