I’ve been trying to useorg.apache.commons.net.telnet.TelnetClient and I am having trouble to receive non-ASCII characters (in my case polish chars like ą,ę,ć,ź and few others). The problem is not on server side – when I use default Ubuntu telnet implementation or Putty I have no problem receiving non-ASCII characters. My code looks something like this (simplified a bit for readability): I
Tag: apache-commons
Jetty 11 and commons-fileupload
I am updating Jetty9 to Jetty11. I updated my package from javax.servlet to jakarta.servlet because servlet 5.0 is the prerequisite for Jetty11. but the problem is when I am using commons-fileupload`-1.4.jar as it is still using java.servlet package. The above method is expecting argument from java.servlet package. Latest version for commons-fileupload – https://search.maven.org/classic/#search%7Cga%7C1%7Ca%3A%22commons-fileupload%22%20AND%20g%3A%22commons-fileupload%22 Do we have any way to overcome
How to avoid backslash before comma in CSVFormat
I am creating a CSV file using CSVFormat in java, the problem i am facing in both header and values is whenever the string is long and there is a comma the api is inserting a before the comma always. As a result the header is not forming correctly and the values in the csv file is taking next
How to unescape HTML 5 entities in Java (')
The answers to this question mostly suggest to use apache-common-text StringEscapeUtils. But this (latest version of commons-text is 1.9) only supports HTML 4, and Mastodon appears to use HTML 5 which includes '. How can I decode HTML 5 entities, including '? Answer unbescape does the job well: Result: Maven:
POIXMLException when updating excel file with apache-poi
When I try overwrite existing excel file, I get this error message: By the way, there is no problem if I try write a new excel file.So Its working correctly but I can’t update existing file. What am I doing wrong? There is my code: Answer Multiple issues in your code. If you are creating an OPCPackage or a XSSFWorkbook
Apache Commons: UnsupportedZipFeatureException (LZMA)
I want to unzip .zip files (with .jpg files inside) that were created using Windows 10’s zipping feature. First I tested it with Java 8’s native util.zip.ZipEntry but kept getting an invalid CEN header (bad compression method) error, which seems to be caused by an incompatibility with Win10’s compression. Because of that I switched to Apache Common’s Compress library (version
What is the point of Apache Lang3 StopWatch.split()?
I am currently evaluating implementations between Apache StopWatch and Guava’s Stopwatch and the split functionality in the former intrigued me, but I am struggling to understand what exactly it does, and what value it has. According to the documentation for StopWatch: https://commons.apache.org/proper/commons-lang/javadocs/api-3.9/org/apache/commons/lang3/time/StopWatch.html split() the watch to get the time whilst the watch continues in the background. unsplit() will remove the
Invoke private static method with MethodUtils from Apache commons-lang3
Is it possible to invoke a private static method with MethodUtils? This code throws the exception: If I change method’s access modifier to public it works. Answer No, because MethodUtils.invokeStaticMethod() calls Class.getMethod() under the hood. Even if you try to hack the modifier it won’t be visible to the MethodUtils as it won’t see the modified Method reference: will still
NoClassDefFoundError: org/apache/commons/lang3/StringUtils
I’m trying to run the sample project with this library and I get the following error: I’ve added commons-lang-2.6.jar & commons-lang3-3.1-sources.jar in libs and classpath Main class: I have referred to the following links: java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils from BaseClassLoader Struts 2 framework demo http://apache-commons.680414.n4.nabble.com/lang-java-lang-NoClassDefFoundError-org-apache-commons-lang-StringUtils-Exception-td3735881.html Answer I have added commons-lang-2.6.jar & commons-lang3-3.1-sources.jar… Here’s your problem: commons-lang-2.6.jar doesn’t contain the org.apache.commons.lang3 package, since
Apache Commons Text StringEscapeUtils vs JSoup for XSS prevention?
I want to clean user input for help preventing XSS attacks and we don’t necessarily care to have a HTML whitelist, as our users shouldn’t need to post any HTML / CSS. Eyeing the alternatives out there, which would be better? [Apache Commons Text’s StringEscapeUtils] [1] or [JSoup Cleaner][2]? Thanks! Update: I went with JSoup after writing some unit tests