Questions tagged [apache-commons-lang3]

Apache Commons Lang3 provides a number of helper classes for things that are deemed missing in the Java base libraries. This includes string handling, mathematics helpers, reflection helpers, concurrency and others. Version 3 is a backwards incompatible version update of the original Apache Commons Lang library.

Apache Commons Lang 3 is the latest version of the library.

Note that Lang 3.0 (and subsequent versions) use a different Java package (org.apache.commons.lang3) than the previous versions (org.apache.commons.lang), allowing it to be used at the same time as an earlier version.

Official Website: http://commons.apache.org/lang/

Useful Links:

Related Tags:

80 questions
3
votes
0 answers

Fatal Exception: java.lang.NoSuchMethodError for org.apache.commons.lang3.tuple.Pair

I need to compare two custom objects which are complex. Instead of overriding the equals method I used the apache.commons.lang3 method EqualsBuilder.reflectionEquals(obj1, obj2). It works all fine on most of the Android devices. But for Xiaomi the…
user2234
  • 1,282
  • 1
  • 21
  • 44
3
votes
1 answer

how can I use StrSubstitutor with and empty variable suffix?

I am trying to use Apache Commons Lang's StrSubstitutor to replace variables in a string marked only using prefixes, e.g. like named parameters markjed with : in an SQL query. Here's the code snippet I am using, which doesn't work. import…
Amnon
  • 2,212
  • 1
  • 19
  • 35
3
votes
2 answers

Find relevant parts in a collection of strings

I've got a set of path…
Tobias Liefke
  • 8,637
  • 2
  • 41
  • 58
2
votes
1 answer

Why is Java's System.getSystemProperty("os.name") wrong?

I've upgraded my PC from Windows 10 to Windows 11 and when I run the following Java code with Java 17, it still returns Windows 10: System.getSystemProperty("os.name") Why is the OS version not updated properly? Is there any location on my PC where…
BullyWiiPlaza
  • 17,329
  • 10
  • 113
  • 185
2
votes
1 answer

Jupyter Notebook with Almond Scala Kernel Runs into Error

Is there a way to identify which library version should I be using for a specific scala version? For example., I want to use commons-lang3 library but whatever version I choose I run into an error. I'm using the Almond notebook and here is the…
joesan
  • 13,963
  • 27
  • 95
  • 232
2
votes
0 answers

StringEscapeUtils.escapeHtml/escapeHtml4 inconsistent between commons-lang and commons-lang3

unit test shows StringEscapeUtils.escapeHtml/escapeHtml4 don't produce same results. trying to upgrade commons-lang(2.6) to commons-lang3(3.9) and found parity-mismatch in escapeHtml/escapeHtml4 methods. for (String s : Stream.generate(()->…
Ron Reynolds
  • 544
  • 5
  • 10
2
votes
1 answer

What is the difference between Apache Common's StrBuilder and Java's StringBuilder?

How is StrBuilder from Apache Commons different from Java's StringBuilder? In Apache Commons I see StrBuilder is deprecated. import org.apache.commons.lang3.text.StrBuilder; StrBuilder sb = new StrBuilder(); Can I use Java's StringBuilder…
2
votes
2 answers

apache commons EnumUtils.isValidEnum(EnumClass, stringValue) shows wierd behavior

I have an Enum as given below: public enum EnumClass { ValOne("ValOne."), ValTwo("ValTwo."), valone("ValOne"), valtwo("ValTwo."), ValThree("ValThree"), ValFour("ValFour"), ValFive("ValFive"), ValSix("ValSix"); private String enumValue; private…
NixRam
  • 509
  • 1
  • 10
  • 21
2
votes
2 answers

Helper methods for creating tuples and tupled functions in Java?

I'm using Java 8 along with the Pair from Apache Commons Lang3. The first thing I am trying to do is get a stream from a List and to take a Function and ultimately create a List>. Currently I am creating a Function>…
steinybot
  • 5,491
  • 6
  • 37
  • 55
2
votes
0 answers

StringUtils not working even with included imports

I trying the code into my application to remove multiple unnecessary spaces: while (cleantext.indexOf(" ") != -1) cleantext = StringUtils.replace(cleantext, " ", " "); But got this message error: Main.java:101: error: cannot find symbol …
Linda Lowela
  • 393
  • 1
  • 3
  • 10
2
votes
2 answers

java.lang.ClassNotFoundException: org.apache.commons.lang.builder.ToStringBuilder

I have the next code: File root = new File("./build/classes"); URLClassLoader classLoader = URLClassLoader.newInstance(new URL[] { root.toURI().toURL() }); Class loadedClass = Class.forName("events.Source", true,classLoader); // JSON --> Java…
jkrlos
  • 133
  • 1
  • 2
  • 11
1
vote
0 answers

adding Apache Commons Lang3 to my Spring Boot project

I am doing a Spring Boot exercise from Baeldung.com. The project has a test class that uses the method randomAlphabetic, which I have traced back to RandomStringUtils, which in turn belongs to Lang3 from Apache Commons. I can't seem to add the…
apex2022
  • 777
  • 2
  • 8
  • 28
1
vote
0 answers

apache lang3:3.9 RandomStringUtils strange behaviour with regex

I got strange behaviour from apache.commons.lang3:3.9 (but everything is ok in 3.5). I use RandomStringUtils.random to generate string with length 350. And it matches regex (that has 300 limit). I can't see any special symbols generated in this…
rvWinkle
  • 13
  • 3
1
vote
2 answers

Apache lang3 works but Apache lang does not. Why?

I have implemented the spring boot project with starter parent pom version 2.0.3. When I try to use import org.apache.commons.lang.StringUtils it throws error import cannot be resolved. Even though my m2 folder…
1
vote
1 answer

Difference between splitByWholeSeparator, splitPreserveAllTokens, and splitByWholeSeparatorPreserveAllTokens

In the org.apache.commons.lang3.StringUtils class, what is the difference between splitByWholeSeparator(String, String), splitPreserveAllTokens(String, String) and splitByWholeSeparatorPreserveAllTokens(String, String)? I checked the JavaDoc and it…
Eric
  • 6,563
  • 5
  • 42
  • 66