Questions tagged [apache-stringutils]

StringUtils is a class belonging to Apache Commons package. It offers utility methods for dealing with strings.

112 questions
3
votes
1 answer

StringUtils class not found

I wrote a console application which reads a text file to String and then processes the file contents. I used maven in my project, enabled autoimport, added proper dependencies but still, when I try to process the String by using replace() method…
JacekDuszenko
  • 136
  • 2
  • 11
3
votes
3 answers

Understanding StringUtils.join performance decisions

I was looking at the implementation of Apache Commons' StringUtils.join method and stumbled upon a line I assume is thought for performance but I don't understand why they did it the way it is, with those specific values. Here's the…
dabadaba
  • 9,064
  • 21
  • 85
  • 155
3
votes
1 answer

StringUtils.countMatches() isn't working for tab char

I am validating a csv file with content like: TEST;F;12345;0X4321 - 1234 DUMMYTEXT;0X4321 - 1234 TESTTEXT Until now, the values were seperated by ';' and the method worked like a charm: private static final String COLUMN_SEPARATOR = ";"; public…
SME_Dev
  • 1,880
  • 13
  • 23
3
votes
3 answers

Use case for String split

I want code snippet for splitting the below string: Input : select * from table where a=? and b=? and c=? Output: Str1: select * from table where a=? Str2: and b=? Str3: and c=? I do not want to use indexof as of now, whether…
Rahul
  • 41
  • 2
3
votes
5 answers

Possible null pointer exception in string utils

I am using commons StringUtils.isNotBlank() to check if a string is not empty and blank. In some scenarios for a blank string or a null as input validation is not happening as expected. Null or blank is getting through. if(…
om39a
  • 1,406
  • 4
  • 20
  • 39
2
votes
4 answers

How to replace multiple occurrence of same regex pattern in a String with different values in Java

Consider a sample example as below: String string = "Hi$?Hello$?". In the string object the "$?" is the regex pattern. The first occurrence of the $? has to replaced with "there" and second occurrence of the $? has to replaced with "world". How to…
Vishal
  • 53
  • 6
2
votes
1 answer

How to remove a comma from a particular field in csv file in java

My code below is printing the columns with the data. I tried putting escapeCsv method of StringEscapeUtils but comma does not still go from the name…
Aria
  • 47
  • 6
2
votes
2 answers

String.split vs StringUtils.split in Java gives different results

Consider a string like below with delimiter __|__. String str = "a_b__|__c_d"; str.split("__\\|__") gives 2 splits a_b and c_d StringUtils.split(str, "__|__") or StringUtils.split(str, "__\\|__") gives 4 splits a, b, c, d which is not desired. Is…
user1013528
  • 93
  • 1
  • 2
  • 9
2
votes
3 answers

remove extra white space and invisible chars from string using java

I have a big conversation, I am handling it as String in between the string there are many white spaces may be invisible non word characters also. Below is an example string: public static void main(String[] args) { String str = " TWD day count…
Sanvi
  • 75
  • 2
  • 9
2
votes
1 answer

NoClassDefFoundError for apache/commons/lang/StringUtils

I want to use commons-lang3 in my project, with Android Studio. Here is my gradle configuration: compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.4' Gradle build is done without error, I can use StringUtils. But in runtime,…
Florian Mac Langlade
  • 1,863
  • 7
  • 28
  • 57
2
votes
1 answer

Add exclude apache.commons.lang3 from net.sourceforge.dynamicreports

I want to add a dependency in my project to use dynamic report, i found this: net.sourceforge.dynamicreports dynamicreports-core 4.0.0 but when i…
Sidaoui Majdi
  • 399
  • 7
  • 26
2
votes
1 answer

How can I get Ant to "chomp" newlines at the end of files?

I'm using the Ant LoadFile task to read the version from a file in the repository root. The version file ends with a newline due to the tooling used to create and edit it. Ant is reading and…
Anthony Mastrean
  • 21,850
  • 21
  • 110
  • 188
2
votes
4 answers

toString() in POJO Class

Is it required to add toString() in all the POJO classes? Its kind of a very basic question but I am worried about writing a piece of code in each n every POJO classes. I have followed many java sources and I found a common things in those POJO…
Mithun Khatri
  • 636
  • 3
  • 9
  • 22
2
votes
2 answers

Apache StringUtils Split Function does Crazy

I was wondering about this crazy thing in StringUtils.split(string,separator); I want to separate a string using a separator @@--@@ and my code goes like this. String[] strings =…
ashokramcse
  • 2,841
  • 2
  • 19
  • 41
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