Example usage for java.lang Integer toHexString

List of usage examples for java.lang Integer toHexString

Introduction

In this page you can find the example usage for java.lang Integer toHexString.

Prototype

public static String toHexString(int i) 

Source Link

Document

Returns a string representation of the integer argument as an unsigned integer in base 16.

Usage

From source file:Main.java

public static String interceptionString(int version) {
    String st = Integer.toHexString(version).toString();
    int a = Integer.valueOf(st.substring(0, 1));
    int b = Integer.valueOf(st.substring(1, 3));
    int c = Integer.valueOf(st.substring(3, 5));
    st = "v" + a + "." + b + "." + c;
    return st;/*from   w  w w. j  av a  2  s.co  m*/
}

From source file:Main.java

public static String convertColorToHexString(java.awt.Color c) {
    String str = Integer.toHexString(c.getRGB() & 0xFFFFFF);
    return ("#" + "000000".substring(str.length()) + str.toUpperCase());
}

From source file:Main.java

public static String tohex(int i) {
    if (i < 16) {
        return "0" + Integer.toHexString(i).toUpperCase();
    }/*from   ww w  .  j  a va  2s.com*/
    return Integer.toHexString(i).toUpperCase();
}

From source file:Utils.java

public static String getHTMLColorString(Color color) {
    String red = Integer.toHexString(color.getRed());
    String green = Integer.toHexString(color.getGreen());
    String blue = Integer.toHexString(color.getBlue());

    return "#" + (red.length() == 1 ? "0" + red : red) + (green.length() == 1 ? "0" + green : green)
            + (blue.length() == 1 ? "0" + blue : blue);
}

From source file:Main.java

public static Integer getNetworkFromInteger(Integer addr) {
    return Integer.valueOf(Integer.toHexString(addr).substring(0, 1), 16);
}

From source file:Main.java

public static byte convertToByte(int input) {
    byte out = 0x00;
    String str16 = Integer.toHexString(input);
    out = Byte.parseByte(str16, 16);
    return out;/* w w  w.j a va 2s  .co m*/
}

From source file:Main.java

private static String hex(int i) {
    return "0x" + Integer.toHexString(i) + " ";
}

From source file:Main.java

public static byte[] decimalToHexBytes(int deci) {
    String hexStr = Integer.toHexString(deci);
    return hexStringToBytes(hexStr);
}

From source file:Main.java

public static String toRegularHashCode(String string) {
    final String hexHashCode = Integer.toHexString(string.hashCode());
    final StringBuilder stringBuilder = new StringBuilder(hexHashCode);
    while (stringBuilder.length() < 8) {
        stringBuilder.insert(0, '0');
    }/*  w ww .j  a v  a2s  .com*/
    return stringBuilder.toString();
}

From source file:Main.java

public static String toHexString(int c) {
    return "#" + Integer.toHexString(c);
}