Split & join string

I have a rowset. I need to combine the elements of this collection into one line, and then split this line back and get the original collection of rows. Specifically, I need to enter a separator character for a join / split operation. Given the fact that source strings can contain any characters, I also need to deal with demarcation. My question is very simple - is there a Java class / library that can provide me with the necessary functionality out of the box? Something like:

String join(String[] source, String delimiter, String escape); String[] split(String source, String delimiter, String escape); 

or similar, without having to do manual work?

+8
java
source share
2 answers

Without the accelerating part there is:

  • StringUtils.split(..) and StringUtils.join(..) from commons-lang
  • Joiner and Splitter from guava .
+6
source share

Separation: String.split takes a regular expression pattern as an argument (delimiter) and returns the result of String[] .

+1
source share

All Articles