tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 Tools and Libs > Ostermiller Utilities > String Prepad Integer

String Prepad Integer 

Ostermiller Java Utilities contain various components such as CSV parsing, Base64 Encoding, MD5 digest, String and Exec Helper classes. This requires the library ostermillerutils-1.08.01.jar to be in classpath. The following example shows using StringHelper.prepad() API.

File Name  :  
com/bethecoder/tutorials/ostermillerutils/StringPrepadIntTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.ostermillerutils;

import java.io.IOException;

import com.Ostermiller.util.StringHelper;

public class StringPrepadIntTest {

  /**
   @param args
   @throws IOException 
   */
  public static void main(String[] argsthrows IOException {

    int num = 123;
    String str = StringHelper.prepad(num, 8);
    System.out.println(str);
  
    num = 123123;
    str = StringHelper.prepad(num, 8);
    System.out.println(str);
    
    num = 12123123;
    str = StringHelper.prepad(num, 8);
    System.out.println(str);
  }

}
   

It gives the following output,
00000123
00123123
12123123


                    Print

   



Books Recommendation

 
 
bl  br