Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A method to reverse effect of java String.split()? [duplicate]

Tags:

java

string

split

I am looking for a method to combine an array of strings into a delimited String. An opposite to split().

Wanted to ask the forum before I try writing my own (since the JDK has everything)

like image 629
javaphild Avatar asked Apr 27 '09 16:04

javaphild


People also ask

Which method is used to reverse the string in Java?

The String class requires a reverse() function, hence first convert the input string to a StringBuffer, using the StringBuffer method. Then use the reverse() method to reverse the string.

Which method is used to reverse the string?

Reverse a String using String Builder / String Buffer Class. StringBuffer and StringBuilder comprise of an inbuilt method reverse() which is used to reverse the characters in the StringBuffer. This method replaces the character sequence in the reverse order.


1 Answers

There's no method in the JDK for this that I'm aware of. Apache Commons Lang has various overloaded join() methods in the StringUtils class that do what you want.

like image 50
John Topley Avatar answered Oct 08 '22 22:10

John Topley