Example usage for java.lang Integer toOctalString

List of usage examples for java.lang Integer toOctalString

Introduction

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

Prototype

public static String toOctalString(int i) 

Source Link

Document

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

Usage

From source file:Main.java

public static void main(String[] args) {
    System.out.println(Integer.toOctalString(7));
    System.out.println(Integer.toOctalString(8));
    System.out.println(Integer.toOctalString(9));
    System.out.println(Integer.toOctalString(10));
    System.out.println(Integer.toOctalString(100));
}

From source file:MainClass.java

public static void main(String[] arg) {
    System.out.println(Integer.toOctalString(10));

}

From source file:Main.java

public static void main(String[] args) {

    System.out.println(Integer.toOctalString(27));

}

From source file:Main.java

public static void main(String[] args) {
    int i = 27;/*from   ww  w  .j  a v a 2s .co m*/

    String strOctalNumber = Integer.toOctalString(i);
    System.out.println(strOctalNumber);
}

From source file:Main.java

public static void main(String[] args) {
    int integer = 1024;

    String octal = Integer.toOctalString(integer);

    System.out.printf("Octal value of %d is '%s'.\n", integer, octal);
    System.out.printf("Octal value of %1$d is '%1$o'.\n", integer);

    int original = Integer.parseInt(octal, 8);
    System.out.printf("Integer value of octal '%s' is %d.", octal, original);
}

From source file:MainClass.java

public static void main(String args[]) {
    int i = 11;
    System.out.println("Octal is " + Integer.toOctalString(i));
}

From source file:Main.java

public static void main(String args[]) {
    int num = 19648;

    System.out.println(num + " in binary: " + Integer.toBinaryString(num));

    System.out.println(num + " in octal: " + Integer.toOctalString(num));

    System.out.println(num + " in hexadecimal: " + Integer.toHexString(num));
}

From source file:Main.java

/**
 * Convert decimalism to other.//from   www  .j  a  v a 2  s .  c o m
 * @param decimal Value in decimalism.
 * @param radix Which system to convert. (Only 2, 8, 16)
 */
public static String toBits(int decimal, int radix) {
    String num;
    switch (radix) {
    case 2:
        num = "00000000000000000000000000000000" + Integer.toBinaryString(decimal);
        return "0b" + num.substring(num.length() - 32);
    case 8:
        num = "00000000000" + Integer.toOctalString(decimal);
        return "0" + num.substring(num.length() - 11);
    case 16:
        num = "00000000" + Integer.toHexString(decimal);
        return "0x" + num.substring(num.length() - 8);
    default:
        return UNKNOWN;
    }
}

From source file:com.vake.ArrayUtils.java

/**
 * ?radix<p/>//  w ww . j av a2 s .  c  o  m
 * bytesnull"null"bytes"[]"
 *
 * @param bytes                 
 * @param radix2?816
 * @return 
 */
public static String toString(byte[] bytes, int radix) {
    if (2 != radix && 8 != radix && 16 != radix) {
        final String msg = "radix must be 2, 8 or 16";
        throw new IllegalArgumentException(msg);
    }
    if (null == bytes) {
        return "null";
    }

    final StringBuilder builder = new StringBuilder("[");
    final int len = bytes.length;
    for (int i = 0; i < len; i++) {
        final int intValue = bytes[i] & 0xFF;
        final String string;
        final String padString;
        switch (radix) {
        case 2:
            string = Integer.toBinaryString(intValue);
            padString = StringUtils.leftPad(string, 8, '0');
            break;
        case 8:
            string = Integer.toOctalString(intValue);
            padString = StringUtils.leftPad(string, 3, '0');
            break;
        default:
            string = Integer.toHexString(intValue);
            padString = StringUtils.leftPad(string, 2, '0');
        }
        builder.append(padString.toUpperCase());
        if (i < len - 1) {
            builder.append(", ");
        }
    }
    builder.append("]");
    return builder.toString();
}

From source file:blankd.acme.pet.licensing.Application.java

@Override
public void run(String... arg0) throws Exception {
    Boolean runLoad = Boolean.valueOf(loadData);
    Account adminOwner = new Account("blankd", "Nothing", "Nothing", "Nothing", "Nothing", AccountTypes.ADMIN);
    Account clerkOwner = new Account("workerblank", "Nothing", "Nothing", "Nothing", "Nothing",
            AccountTypes.CLERK);/*from   w w w  .  j a v a2s  . co m*/
    Account petOwner = new Account("superblank", "Nothing", "Nothing", "Nothing", "Nothing", AccountTypes.USER);
    aRepo.save(adminOwner);
    aRepo.save(clerkOwner);
    aRepo.save(petOwner);
    if (runLoad) {
        List<License> inserting = new ArrayList<License>();
        String[] names = petNames.split(",");
        String[] animals = species.split(",");
        Integer assignedLicenses = ZERO;
        for (Integer i = ZERO; i < maxLicense; i++) {
            String license = Integer.toOctalString(i);
            Boolean assignLicense = this.randomBoolean();
            if (assignedLicenses < this.maxAssigned && assignLicense) {
                String assignName = names[this.randomNumber(names.length)];
                String assignSpecies = animals[this.randomNumber(animals.length)];
                log.debug("Assigning Name " + assignName);
                log.debug("Assigning Species " + assignSpecies);
                assignedLicenses++;
                Pet thePet = new Pet(assignName, assignSpecies, Pet.NONE);
                pRepo.save(thePet);
                log.debug("pet id is " + thePet.getId());
                repo.save(new License(license, thePet, this.generateExpirationDate(), petOwner));
            } else {
                log.debug("Generating License " + license);
                repo.save(new License(license, null, null, null));
            }
        }
        log.debug("Assigned " + assignedLicenses + " licenses");

        Account find = aRepo.findByUsername("blankd");
        log.debug(find.getUsername() + " has " + find.getLicences().size() + " pets");
    }
}