Skip to content

Tag: java

Navigating the file system with netbeans is VERY slow

Since a few days, navigating the file system with Netbeans is VERY slow (more than two minutes to access a file, and if you have to navigate a file system, it is true every time. I have exactly the same problem after clearing the cache, and with Netbeans 8.2 and Netbeans 12 (Netbeans 8 with Java 8, and Netbea…

Java cannot find symbol for imported scala class

I received a Scala jar and need to write a java program to use a method. The imported Scala method definitely works because it has been in production for years. here is the program: Decompiled Scala code: Here are observations: Error message: cannot find symbol constructor VerifyApp() location: class com.comp…

Why do I have to set AuthenticationManager twice

In my application I’ve implemented X.509 authentication I created the following class named X509AuthenticationFilter that extends AbstractPreAuthenticatedProcessingFilter provided by spring security by default. I added my own AuthenticationManager to the class And also included the following setter The …

How to check in which line of text the word is

I’m doing an exercise where I need to count how many times a word appears on a text and I also need to print in which line the words are present. Text example: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim ven…

Compare two dates in years with comma and leap year

There are many entries on the internet how the difference between two dates can be compared. However, I still haven’t found the right solution for me. In short: I’m looking for the equivalent of dayjs (javascript library – dayJs) function diff with the parameter “years” and a com…

Storing a temporary value of a constantly changing variable

I would like to know, is it possible to store a temporary value of a variable before it switches to another one? Following is the code snippet: Answer You need to have a sum variable before the for cycles, and in the first for, after the second, have the sum add the counter.

Java filtering the object list to string array with stream

I have a class like this and static function like this The problem is inside of filterLength function I can’t return stream as a String array(I want to return content in the Host class) because List holds Host object how can I return as a string in 1 line code? Answer Transform each object in stream You…