tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 Tools and Libs > Jodd > Strings > String prefix

String prefix 

Jodd is an open-source java library with lot of reusable components and feature rich utilities. This requires the library jodd-3.3.2.jar to be in classpath. The following example shows how to use StringUtil.prefix() API. It inserts prefix if the given string doesn't start with specified prefix.

File Name  :  
com/bethecoder/tutorials/jodd/utils/StringPrefixTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.jodd.utils;

import jodd.util.StringUtil;

public class StringPrefixTest {

  /**
   @param args
   */
  public static void main(String[] args) {
    System.out.println(StringUtil.prefix("aaaa""B"));
    System.out.println(StringUtil.prefix("Baaaa""B"));
    
    System.out.println(StringUtil.prefix("acac""c"));
    System.out.println(StringUtil.prefix("acac""ac"));
    
    System.out.println(StringUtil.prefix("AAAA""A"));
    System.out.println(StringUtil.prefix("AAAA""B"));
  }

}
   

It gives the following output,
Baaaa
Baaaa
cacac
acac
AAAA
BAAAA


                    Print

   



Books Recommendation

 
 
bl  br