Example usage for java.lang Integer toString

List of usage examples for java.lang Integer toString

Introduction

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

Prototype

public static String toString(int i, int radix) 

Source Link

Document

Returns a string representation of the first argument in the radix specified by the second argument.

Usage

From source file:Main.java

public static void main(String[] args) {
    System.out.println(Integer.toString(100, 2));
    System.out.println(Integer.toString(100, 8));
    System.out.println(Integer.toString(100, 10));
    System.out.println(Integer.toString(100, 16));
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    int i = 42;//from  w  w w  .j av a2  s .c o m
    String hexstr = Integer.toString(i, 16);
    System.out.println(hexstr);
    hexstr = Integer.toHexString(i);
    System.out.println(hexstr);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int i = Integer.parseInt("1000", 8);
    String s = Integer.toString(i, 8);
    System.out.println(s);//from w  ww. ja  v a  2s  .  c  om
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int i = Integer.parseInt("3ff", 16);
    String s = Integer.toString(i, 16);
    System.out.println(s);/* w w  w  .  j a  v  a 2  s  .c  o m*/
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int radix = 32;
    int i = Integer.parseInt("vv", radix);
    String s = Integer.toString(i, radix);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int i = 1023;

    i = Integer.parseInt("1111111111", 2);
    String s = Integer.toString(i, 2);
    System.out.println(s);//  w w w. j  av  a 2s . c om
}

From source file:Main.java

public static void main(String[] argv) {
    byte[] b = "ada".getBytes();

    for (int i = 0; i < b.length; i++) {
        System.out.println(Integer.toString((b[i] & 0xff) + 0x100, 16).substring(1));
    }//from ww  w  . j  a  v a2s .c om

}

From source file:Main.java

public static void main(String args[]) throws Exception {
    InputStream fis = new FileInputStream("a.exe");

    byte[] buffer = new byte[1024];
    MessageDigest complete = MessageDigest.getInstance("MD5");
    int numRead;//  w  w  w .  j  a  va  2  s  .  c  o  m
    do {
        numRead = fis.read(buffer);
        if (numRead > 0) {
            complete.update(buffer, 0, numRead);
        }
    } while (numRead != -1);
    fis.close();

    byte[] b = complete.digest();
    String result = "";
    for (int i = 0; i < b.length; i++) {
        result += Integer.toString((b[i] & 0xff) + 0x100, 16).substring(1);
    }
    System.out.println(result);

}

From source file:Main.java

public static String getHexString(byte[] b) {
    String result = "";
    for (byte b2 : b) {
        result = result + Integer.toString((b2 & 255) + 256, 16).substring(1);
    }/*from  w w w  .  j  a v  a2  s  .c o  m*/
    return result;
}

From source file:Main.java

public static String getHexString(final byte[] b) {
    String result = "";
    for (int i = 0; i < b.length; i++) {
        result += Integer.toString((b[i] & 0xff) + 0x100, 16).substring(1);
    }/*from  ww w .  j a  va 2 s . com*/
    return result;
}