Example usage for java.math BigInteger toString

List of usage examples for java.math BigInteger toString

Introduction

In this page you can find the example usage for java.math BigInteger toString.

Prototype

public String toString(int radix) 

Source Link

Document

Returns the String representation of this BigInteger in the given radix.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    BigInteger bi = new BigInteger("1000", 8);
    s = bi.toString(8);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    BigInteger bi = new BigInteger("3ff", 16);
    String s = bi.toString(16);

}

From source file:Main.java

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

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    byte[] bytes = new byte[] { (byte) 0x12, (byte) 0x0F, (byte) 0xF0 };

    // Create a BigInteger using the byte array
    BigInteger bi = new BigInteger(bytes);

    String s = bi.toString(2);
    System.out.println(s);/*from w  w  w.j a  v  a2  s .c  o m*/

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    byte[] bytes = new byte[] { (byte) 0x12, (byte) 0x0F, (byte) 0xF0 };

    BigInteger bi = new BigInteger(bytes);

    // Format to octal
    String s = bi.toString(8);
    System.out.println(s);//from   w  w  w .j a v a  2s .c  o  m

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    byte[] bytes = new byte[] { (byte) 0x12, (byte) 0x0F, (byte) 0xF0 };

    BigInteger bi = new BigInteger(bytes);

    // Format to hexadecimal
    String s = bi.toString(16);
    if (s.length() % 2 != 0) {
        s = "0" + s;
    }/*  w  w  w  .  j a va 2 s  .  c  o m*/
}

From source file:Main.java

public static void main(String[] args) {

    BigInteger bi1 = new BigInteger("16");
    BigInteger bi2 = new BigInteger("-16");

    System.out.println(bi1.toString(8));
    System.out.println(bi2.toString(2));
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    CertificateFactory cf = CertificateFactory.getInstance("X.509");

    List mylist = new ArrayList();

    FileInputStream in = new FileInputStream(args[0]);
    Certificate c = cf.generateCertificate(in);
    mylist.add(c);/*from ww  w  .  ja  v a2 s.  c o m*/

    CertPath cp = cf.generateCertPath(mylist);

    FileInputStream kin = new FileInputStream(args[0]);
    KeyStore ks = KeyStore.getInstance("JKS");
    ks.load(kin, args[1].toCharArray());

    PKIXParameters params = new PKIXParameters(ks);
    params.setRevocationEnabled(false);

    CertPathValidator cpv = CertPathValidator.getInstance("PKIX");

    PKIXCertPathValidatorResult result = (PKIXCertPathValidatorResult) cpv.validate(cp, params);

    PublicKey pbk = result.getPublicKey();
    byte[] pkenc = pbk.getEncoded();
    BigInteger pk = new BigInteger(pkenc);
    System.out.println(pk.toString(16));

    TrustAnchor anc = result.getTrustAnchor();
    X509Certificate xc = anc.getTrustedCert();
    System.out.println(xc.getSubjectDN());
    System.out.println(xc.getIssuerDN());

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    BigInteger bi = new BigInteger("1023");
    // Parse and format to binary
    bi = new BigInteger("1111111111", 2);
    String s = bi.toString(2);
}

From source file:Main.java

public static void main(String[] args) {
    BigInteger number = new BigInteger("2008");

    System.out.println("Number      = " + number);
    System.out.println("Binary      = " + number.toString(2));
    System.out.println("Octal       = " + number.toString(8));
    System.out.println("Hexadecimal = " + number.toString(16));

    number = new BigInteger("FF", 16);
    System.out.println("Number      = " + number);
    System.out.println("Number      = " + number.toString(16));
}