Questions tagged [string-utils]
50 questions
344
votes
14 answers
StringUtils.isBlank() vs String.isEmpty()
I ran into some code that has the following:
String foo = getvalue("foo");
if (StringUtils.isBlank(foo))
doStuff();
else
doOtherStuff();
This appears to be functionally equivalent to the following:
String foo = getvalue("foo");
if…

NSA
- 5,689
- 8
- 37
- 48
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
20
votes
7 answers
Java Map Values to Comma Separated String
Is there an effective way to convert java map values to comma separated string using guava or StringUtils?
Map testMap = new HashMap<>();
testMap.put("key1", "val1");
testMap.put("key2", "val2");
looking for a way to convert testMap…

l a s
- 3,836
- 10
- 42
- 61
7
votes
2 answers
StringUtils class not working in Android
I am using StringUtils class in Android code. but exception generated i.e. class not found. But already i used jar file for that class. Please help me!

Ranjitsingh Chandel
- 1,479
- 6
- 19
- 33
6
votes
3 answers
What is the difference between split method in String class and the split method in Apache StringUtils?
I am reading a file line by line and want to split each line on the basis of specific delimiter.I found some options available in String class and StringUtils class.
So my question is which is the better option to use and why?

user3717431
- 103
- 2
- 9
5
votes
3 answers
StringUtil indexOf() equivalent postgreSQL query
I need to implement stringUtils Class indexOf() method in postgresql.
Lets say I have a table in which url is one of the column.
url : "http://paypal-info.com/home.webapps.cgi-bin-limit/webscr.cmd-login-submit"
My requirement is to find the index…

Sri
- 1,505
- 2
- 18
- 35
5
votes
3 answers
What to use instead of str-utils functions?
In http://clojure.github.com/clojure-contrib/str-utils-api.html it is written that
String utilities for Clojure
Deprecated since clojure-contrib version 1.2
but it is not written what should I use instead. There are convenient functions like…

Vi.
- 37,014
- 18
- 93
- 148
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
Java apache commons library source license question
I want to use functionality from a certain method in apache commons StringUtils. I currently do not have the option of just using the library as one would normally do. I found the source for the method I need and my question is: am I free…

llm
- 5,539
- 12
- 36
- 30
2
votes
4 answers
Java: How to RegEx or Substring Utils this String?
"Current Peak : 830 300"
How can I get hold of the two numbers, but without the spaces. (There are 5 or more spaces in between each substring)
Using apache's StringUtils I got so far:
String workUnit…

Stephan Kristyn
- 15,015
- 14
- 88
- 147
2
votes
3 answers
Java - How to set a String dynamically during runtime
I have to build an SQL query where I have to replace two params in the String.
The String variable CLEAN_CSV_PATH which represents a path
The String variable LINES_TERMINATED_OS which represents a the escape character \r\n that are needed for…

ErEcTuS
- 777
- 1
- 14
- 33
2
votes
3 answers
How to replace a string in an xml file without loading file contents into memory in java?
My application creates a very big xml file (of about 300K transactions). Each of the transaction will have about 20 xml elements. So it creates a huge xml file. We did not use JAXB or SAX or DOM for creation of xml file as memory is the constraint.…

Bharat Kondapalli
- 21
- 2
2
votes
5 answers
How to efficiently remove all instances of a String from another String?
The problem I am solving is replacing all Strings from another String.
I solved this problem fairly easily on codingbat.com by using String.replaceAll, and doing it until the first String no longer contains the other String.
However, I dislike this…

Jim Smith
- 41
- 5
2
votes
2 answers
JQuery Inflector as fully featured as Rails' ActiveSupport Inflector?
Is there a JQuery plugin with string utils on par with ActiveSupport's Inflector?
I have found this Prototype utils port, but it's missing some of them.

Lance
- 75,200
- 93
- 289
- 503
2
votes
1 answer
Limitation of Decimal places of String datatype from database to HTML page
I'm getting the String type decimal number from the local database.
And
I viewed three decimal places in my UI application(html page).so now i need to limit it as 2 deciaml places.
Example String Amount = "123.786";
change the amount decimal value …

Yellow Flash
- 862
- 2
- 10
- 29