Skip to content
Advertisement

Tag: java

How to read a file into a weighted digraph

I want to implement a weighted digraph for my Assignment. I already have the code (it’s a lot of code, so I can’t post it here), but I want to load the text file into the graph and I’m having a hard time. My problem ist that the file has two Strings and one integer Data. Do you have any

Spring Security: error while loading keystore

I have a working spring boot application, when I do configure it to run in SSL mode as follow: Configuration, which is working for a similar spring boot application and exact same keystore It throws following Exception: Answer Apparently, this exception happens when you target a directory instead of the actual Keystore file: Instead of

Apache Lucene to replace found terms

I’m looking for a way to find-and-replace words basing on queries in a text using Apache Lucene. Example – I have a text “Happy New Year!” and Lucene query “year~2” with fuzzy-detection and some replace characters (“###”). As the result I want the following – “Happy New ###!”. Is there a way to achieve this using Apache Lucene only? Answer

Fail to write the reduce method using Stream API

I need to calculate the total price of all ordered dishes, but I fail to write the reduce method. This is a method signature ( argument has a map of Dish and how many times it was ordered ). So it must be something like this sum of every dish.getPrice * dishQuantaty The fail-code I was asked about Answer Did

Windows AD unable to reset password from code

From code trying to reset AD user password and using the same  password further to login from other services. But AD is not authenticating the user.  In AD we are updating userPassword, holcimIsRegistered and userAccountControl attributes from our code to reset the password. When we are manually resetting AD user password from ADSI (right click on user -> go to reset password → reset the password) then AD is authenticating the user with the new password. Neither userPassword nor unicodePwd attributes

Java remove dupplicate attribute in List

I have list of message, class Message have 2 attribute: The following code below: I want to remove duplicate message from list but must keep the message with the longest time in List Input Expect result Answer This will solve your issue. P.S – plz go through basic data structures available in Java and their use cases.

How to setServletPath() in Spring Junit WebTestClient?

This creates a MockHttpServletRequest that is send to the @RestContoller servlets. Problem: my servlets make use of HttpServletRequest.getServletPath(), but which is always empty using the WebTestClient approach above. Question: how can I explicit set the servletPath in my junit tests? Answer I could solve it as follows, but as this is really hacky, I’d still appreciate a proper solution.

Advertisement