tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Google Guava > Basic > String Pad Start

String Pad Start 

Google Guava is a java library with lot of utilities and reusable components. This requires the library guava-10.0.jar to be in classpath. The following example shows using Strings.padStart() API.

File Name  :  
com/bethecoder/tutorials/guava/base_tests/StringPadStartTest.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.guava.base_tests;

import com.google.common.base.Strings;


public class StringPadStartTest {

  /**
   @param args
   */
  public static void main(String[] args) {
    String str = Strings.padStart("6"4'0');
    System.out.println(str);
    
    str = Strings.padStart("68"4'0');
    System.out.println(str);
    
    str = Strings.padStart(""4'0');
    System.out.println(str);
    
    str = Strings.padStart("2010"4'0');
    System.out.println(str);
    
    str = Strings.padStart("20100"4'0');
    System.out.println(str);
  }
}
   

It gives the following output,
0006
0068
0000
2010
20100



 
  


  
bl  br