Java Integer to intTo8HexString(int i)

Here you can find the source of intTo8HexString(int i)

Description

Create a string with an hexadecimal representation of an integer.

License

Open Source License

Parameter

Parameter Description
i the value to change into string

Declaration

public static String intTo8HexString(int i) 

Method Source Code

//package com.java2s;
/**//  w  ww  .j  av a2 s .c om
 * Copyright? 2005-2006 INRIA/Universit? Pierre Mend?s-France/Universit? Joseph Fourier.
 *
 * O3MiSCID (aka OMiSCID) Software written by Sebastien Pesnel, Dominique
 * Vaufreydaz, Patrick Reignier, Remi Emonet and Julien Letessier.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

public class Main {
    /**
     * Create a string with an hexadecimal representation of an integer. The
     * representation has 8 characters completed by 0.
     *
     * @param i
     *            the value to change into string
     */
    public static String intTo8HexString(int i) {
        String str = Integer.toHexString(i).toUpperCase();
        while (str.length() < 8) {
            str = "0" + str;
        }
        // System.out.println("IntTo8HexString: "+str);
        return str;
    }
}

Related

  1. Int2Short(int i)
  2. int2sortableStr(int val)
  3. int2TwoChars(int i)
  4. intTo2LengthBytes(int i)
  5. intTo2UnsignedBytes(int val)
  6. intToAlgebraicLoc(int loc)
  7. intToAlpha(Integer no)
  8. intToASN1(byte[] d, int idx, int val)
  9. intToBase32(int n)