StringUtils is a class belonging to Apache Commons package. It offers utility methods for dealing with strings.
Questions tagged [apache-stringutils]
112 questions
0
votes
2 answers
Find an String with some keys in java
Consider a map as below:
Map("PDF","application/pdf")
Map("XLSX","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
Map("CVS","application/csv")
....
There is an export method which gets the export button name and find the export…

Alireza Fattahi
- 42,517
- 14
- 123
- 173
0
votes
1 answer
Which would be best to use setMessage(null) or StringUtils.EMPTY?
I need to clear the warning or say error message,which will be the best one to choose
setMessage(null)
or
by using StringUtils.EMPTY - i just want to know the exact way of using StringUtils.EMPTY,it would be helpful...
Thanks & Regards.

user2787836
- 11
- 3
0
votes
1 answer
apache Common StringUtils.replacePattern vs java.lang.String.replaceAll
I am trying to know the pros and cons of using apache.commons.StringUtils.replacePattern() instead of the java.lang.String.replaceAll() function.
I heard that the replacePattern() function improves the performance but I could not find that stated in…

Yeshwanth Kota
- 481
- 1
- 5
- 10
0
votes
1 answer
Count instances of string in string
I'm making some changes to a Java Tapestry application that I didn't build. I need to use a Java class to count the number of times a line break (/r) occurs in a string. Does Tapestry have a built-in tool for doing this, or a reference guide for…

Ila
- 3,528
- 8
- 48
- 76
0
votes
1 answer
cannot find symbol symbol : variable StringUtils
I was trying to print the following statement in my jsp.
out.println("myBookIdStatus="+StringUtils.isEmpty(obj.getValue(0,"value")));
Even though I have imported <%@page import="org.apache.commons.lang.StringUtils"%> , I am getting following…

Nidheesh
- 4,390
- 29
- 87
- 150
0
votes
2 answers
Selective HTML escaping with Java
Is there anything in JavaSE, Spring or Apache Commons StringUtils that would allow me to strip out HTML from a String but also supply a whitelist of HTML entities that I would like to allow?
Thanks

csilk
- 188
- 1
- 15
-1
votes
2 answers
How do I check a string is empty or null using if statement in Java?
I need to get the enum itself first by using RegoDocumentType.getByValue(createOrderRequest.getIdDocument().getIdType())
Then check for null value, if it is not null, it will return the enum value. Else, it will return the…

ginny
- 1
- 2
-1
votes
1 answer
How to capture first paragraph and store in String in java
I have to capture first paragraph characters and need to store in string.If the paragraph contains more than 300 characters we have to capture 300 only.
I wrote some code to do the same but it captures if the paragraph contains 300 or else it tries…

Mahesh C
- 9
- 3
-1
votes
2 answers
import does not seem to be working correctly in Eclipse/Java
I was using the following:
String x;
...
...
// x gets set somewhere in this code
String y = x.replaceAll("\\s+", " ").trim();
Then I found org.apache.commons.lang3.StringUtils.normalizeSpace() which does the same thing. So at the top of my class I…

Tony
- 367
- 1
- 7
- 17
-1
votes
1 answer
Apache commons lang. Stringutils.splitByWholeseparator doing weird stuff.
As I understand from the official documentation, null as a separator string should split on WhiteSpace, so this System.out.println(JSON.serialize(StringUtils.splitByWholeSeparator("ab de fg", null))); should produce [ "ab" , "de" , "fg"]
However,…

VaidAbhishek
- 5,895
- 7
- 43
- 59
-1
votes
1 answer
How does the offset parameter works in the function abbreviate(String str,int offset,int maxWidth), in package org.apache.commons.lang.StringUtils
I am presently working with the apache commons lang package, StringUtils class.
I found there are two abbreviation methods: abbreviate(String str,int maxwidth) and abbreviate(String str,int offset,int maxwidth) it is absolutely ok with the first…

Rivu Chakraborty
- 1,372
- 2
- 12
- 37
-1
votes
1 answer
Why would StringUtils return the incorrect # of matches of a substring?
I am using StringUtils from the apache commons library to check the # of matches of a substring within the source code of an html page.
I have converted the page source using the webdriver command:
String pageSource = driver.getPageSource(); …

kevin
- 37
- 5
- 21
-1
votes
1 answer
Is using StringUtils.EMPTY recommended in unit test where StringUtils.isBlank method is used?
I have function
public void foo(final String s) {
if(StringUtils.isBlank(s) {//throw error}
//rest of the logic
}
and unit test
@Test(//expected exception)
public void testFooWithBlankString() {
ClassOfFoo.foo(StringUtils.EMPTY);
}
Is this…

Rishabh Singhal
- 1,173
- 10
- 22
-1
votes
1 answer
Double closing tags generated
I am using JSOUP library to parse the html.But I was ending up having extra closing tags with encoded <>(< and >) added up in my DOM.Hence I used the String utils library to get rid of that encoded stuff.Hence I still have duplicate closing tags…

Swaraj Chhatre
- 627
- 1
- 10
- 22
-1
votes
1 answer
StringUtils.substringBetween returns null value
I've a problem with the following code:
public String SearchText(String fileName, String First, String Last) {
String tag = new String();
String file = FileUtils.readFileToString(new File(fileName));
tag =…

user1595513
- 1
- 3