StringUtils is a class belonging to Apache Commons package. It offers utility methods for dealing with strings.
Questions tagged [apache-stringutils]
112 questions
                    
                    102
                    
            votes
                
                19 answers
            
        Extract digits from string - StringUtils Java
I have a String and I want to extract the (only) sequence of digits in the string. 
Example:
helloThisIsA1234Sample.
I want the 1234
It's a given that the sequence of digits will occur only once within the string but not in the same position.
(for…
         
    
    
        NinaNa
        
- 1,575
- 6
- 15
- 21
                    58
                    
            votes
                
                1 answer
            
        Concatenate string values with delimiter handling null and empty strings?
In Java 8 I have some number of String values and I want to end up with a comma delimited list of valid values.  If a String is null or empty I want to ignore it.  I know this seems common and is a lot like this old question; however, that…
         
    
    
        eze
        
- 2,332
- 3
- 19
- 30
                    25
                    
            votes
                
                1 answer
            
        Converting a List to comma separated string 
        Hi I am having a requirement where I need to convert List of Long datatype to comma separated String. 
Which would be the appropriate way. I have thought about using string builder or converting it to List and then using StringUtils join to… 
         
    
    
        user2375298
        
- 1,001
- 4
- 15
- 28
                    12
                    
            votes
                
                1 answer
            
        decode string encoded in utf-8 format in android
I have a string which comes via an xml , and it is text in German. The characters that are German specific are encoded via the UTF-8 format. Before display the string I need to decode it. 
I have tried the following:
try {
    BufferedReader in =…
         
    
    
        user590849
        
- 11,655
- 27
- 84
- 125
                    10
                    
            votes
                
                6 answers
            
        Apache StringUtils vs Java implementation of replace()
What would be the difference between Java 1.4.2's implementation of replace, and Apache 2.3's implementation? Is there a performance gain one over another?
Java 1.4.2 replace
Apache 2.3 replace
         
    
    
        Oh Chin Boon
        
- 23,028
- 51
- 143
- 215
                    8
                    
            votes
                
                2 answers
            
        Convert a list of Person object into a separated String by getName() property of Person object
Is there a XXXUtils where I can do 
String s = XXXUtils.join(aList, "name", ",");
where "name" is a JavaBeans property from the object in the aList.
I found only StringUtils having join method, but it only transforms a List into a separated… 
         
    
    
        Cosmin Cosmin
        
- 1,526
- 1
- 16
- 34
                    7
                    
            votes
                
                3 answers
            
        Why can't I use Apache's StringUtils.join on a List?
When I try
StringUtils.join(myList,',');
I get a compilation failure:
cannot find symbol
symbol  : method join(java.util.List,char)
But the following works:
StringUtils.join(myList.toArray(),',');
The docs (Apache Commons Lang 2.5) seem to…
         
    
    
        Eric Wilson
        
- 57,719
- 77
- 200
- 270
                    6
                    
            votes
                
                2 answers
            
        StringUtils isNumeric returns true when input is "???", why?
I was reading the commons.apache.org isNumeric method definition and it states: 
StringUtils.isNumeric("???") = true;
I am not sure why "???" is considered to be numeric.  My guesses are:
A "?" is considered a unicode digit
It is some kind of…
         
    
    
        dspano
        
- 1,540
- 13
- 25
                    6
                    
            votes
                
                1 answer
            
        Inverse function to StringUtils.capitalize()
There is convenient method StringUtils.capitalize() in apache-commons-lang library. But I can not find pairwise inverse method for it, which will make first letter in word in lowercase. Does such method exists?
         
    
    
        Denys
        
- 133
- 2
- 7
                    5
                    
            votes
                
                1 answer
            
        Escaping characters to avoid XSS in Java
I need to escape characters to avoid XSS. I am using org.apache.commons.lang.StringEscapeUtils.escapeHtml(String str), which helps in the following way:
Raw input
" onmouseover=alert() src="
After escaping HTML becomes
" onmouseover=alert()…
         
    
    
        user1532449
        
- 322
- 4
- 14
                    5
                    
            votes
                
                3 answers
            
        apache commons lang3 stringutils taglib
Id like to use StringUtils.abbreviate() inside a jstl tag, is there a taglib location for this?
Ive searched the commons site and the web but an unable to find an example. Is there a common way to find taglib locations also, maybe in a standard…
         
    
    
        nfvindaloo
        
- 948
- 2
- 11
- 24
                    4
                    
            votes
                
                1 answer
            
        Calling Java Apache StringUtils.join() from Groovy
I am attempting to call the Apache Commons StringUtils.join() method from within a Groovy class.  I want to concatenate 3 strings (part1, part2, and part3).  
Why doesn't this work? 
def path = StringUtils.join([part1, part2, part3]) //1
But the…
         
    
    
        Ryan
        
- 1,370
- 1
- 13
- 31
                    4
                    
            votes
                
                1 answer
            
        How to get real end index of string found in another string
I am trying to get a range of chars found in another string using Java:
String input = "test test2 Test3";
String substring = "test2";
int diffStart = StringUtils.indexOf(input, substring);
int diffEnd = StringUtils.lastIndexOf(input,…
         
    
    
        Reddy SK
        
- 1,334
- 4
- 19
- 27
                    4
                    
            votes
                
                2 answers
            
        StringUtils to split based on comma and space
Could you please let me know whether we have any StringUtils function to split based on comma and space. Basically i am wondering whether we have any function which will split based on two delimiters. I have written custom function to do the same,…
         
    
    
        Adam
        
- 727
- 4
- 11
- 21
                    4
                    
            votes
                
                1 answer
            
        Cannot resolve symbol "StringUtils"
I have downloaded "commons-lang-2.6.jar" and added to my java project but I can't use StringUtils. Is there another jar file I should download or I have to change something in the project structure?
         
    
    
        AliBZ
        
- 4,039
- 12
- 45
- 67