tl  tr
  Home | Tutorials | Articles | Videos | Products | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 Tools and Libs > Google Guava > Basic > Joiner Use For Null

Joiner Use For Null 

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 Joiner class. It joins the given strings with provided separator.

File Name  :  
com/bethecoder/tutorials/guava/base_tests/JoinNullReplaceTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.guava.base_tests;

import com.google.common.base.Joiner;

public class JoinNullReplaceTest {

  /**
   @param args
   */
  public static void main(String[] args) {
    Joiner joiner = Joiner.on(":").useForNull("<nil>");
    String str = joiner.join("One", null, null, "Two""Three", null, "Four")
    System.out.println(str);
  }

}
   

It gives the following output,
One:<nil>:<nil>:Two:Three:<nil>:Four


                    Print

   


Books Recommendation

 
 
bl  br