Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

String Reverse Using StringUtils

                         

In this example we are going to reverse a given string using StringUtils api. In this example we are reversing a string and the reversed string  is delimited by a specific character.

The org.apache.commons.lang.StringUtils class extends Object class and defines certain words related to String handling such as null for null,"" for a zero-length string, ' ' for space characters, Charecter.isWhitespace(char) for whitespace and String.trim() for trim.

The methods used:

reverse(String str): This method is used to reverse the order of a buffered string. It returns a null value if no string is passed i.e StringUtils.reverse(null) = null or StringUtils.reverse("") = "" otherwise reverse order will returns e.g. StringUtils.reverse("bat") = "tab".

reverseDelimited(String str,char separatorChar): This method is used to reverse a String that is delimited by a specific character like "". The strings between the delimiters will not reverse. In this method "str" is string to reverse and "separatorChar" is the separator character.


 The code of the program is given below:

import org.apache.commons.lang.StringUtils;
 
public class StringReverseUsingStringUtils 
{    
    public static void main(String[] args)
    {
    String string = "Hi, How R YOU?";         
    String reverse = StringUtils.reverse(string);
    String delimitedReverse = StringUtils.
reverseDelimited
(string, ' ');               
    System.out.println("\nThe original String: " + string);
    System.out.println("The reversed string: " + reverse);
    System.out.println("The delimited Reverse string: " 
+ delimitedReverse);
    }
}

The output of the program is given below:

C:\rajesh\kodejava>javac StringReverseUsingStringUtils.java
C:\rajesh\kodejava>java StringReverseUsingStringUtils
The original String: Hi, How R YOU?
The reversed string: ?UOY R woH ,iH
The delimited Reverse string: YOU? R How Hi,

Download this example.

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Latest Searches:
html:checkbox is check
d=d^2-4ac
heap
convert java.sql.Time
displaytag
Javascript Menus Image
date to calendar
how to scale image usi
tomcat database conf
analog
TimeTextBox
button setName
what is cckies
get array in java usin
exit
java strings
how to access https
ChartDirector Chart an
msaccess
userid
login jsp
myfaces tomahawk
radio button in html
Flash Dynamic Content
à¹?à¸?à¸?à¹?à¸????à¹?à
how to draw a transpar
NamedQuery
java thread
javascript to display
struts2
Hash Function in Java
java beans
sฦ�ing
Photoshop Drawing Rain
login window
struttutorial
iterator
sybase create command
creating tabs
inset the value into t
decimal
update jsf
Combattons la programm
breakÑ?â??â??Ñ??Ñ?â???
Jasper Reports
How to restore page vi
validate radio button
form capture
gridback
jbossweb installation
shapes in applet
Visual Basic Animation
word count in a file
populate drop down
html:frame
string programe in jav
how to get applicate s
jpf
beans
PHP Date and .....:/pw
SimplyMEPIS 3.4-3 is r
varStatus
value change listener
program to invoke ejb
java arrays
JDBC
struts listbox
ActionScript
multidimensional Array
insert data to text fi
Read Cookies from Serv
Photoshop
ActionSupport.java
PHP Date and .....:/pw
how to find the days b
white spaces are requi
JavaScript functions
break?�¢�????????�
breakå??ç?­?å?????å??ç
java structures
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.