I am trying out the kafka streaming. I am reading messages from one topic and doing groupByKey and then doing the count of groups. But the problem is that the messages count is coming as unreadable “boxes”. If I run the console consumer these are coming as empty strings This is the WordCount code I wrote This is the output
Category: Questions
Throwing own exceptions
I have this class Account Now I also have this exception that I wrote Now I need to throw this exception in the class account,when the searched account number does not exist.Now my question is in which method(or function I think that is the same,please correct me if I’m wrong) do I throw this exception.And after what check.How would I
Trying to mock IntConsumer with Mockito fails
I’m trying to mock IntConsumer: and it fails on the ‘verify’ with below error code: Method threw ‘org.mockito.exceptions.base.MockitoException’ exception. Cannot evaluate $java.util.function.IntConsumer$$EnhancerByMockitoWithCGLIB$$3ee084c4.toString() Answer You need to tell Mockito what method it is supposed to verify on the IntConsumer mock. Your verification code should look something like: See for example the tutorial at Baeldung.
How can I make the corners of my bottom sheet dialog rounded? [duplicate]
This question already has answers here: Round corner for BottomSheetDialogFragment (28 answers) Closed last year. I’m trying to make the top corners of my BottomSheetDialog rounded, but I haven’t had any luck with anything online. This is what I would like for it to look like: No matter what I’ve tried, I keep getting this: I’ve tried the method here
Why can ‘CURRENT_DATE’ not as a parameter when using NamedParameterJdbcTemplate in JAVA?
In mysql,I use this sql and it runs well. select * from student where CREATE_TIME>=DATE_SUB(curdate(),INTERVAL 24 HOUR) Now I want to use the date as a parameter,SO I use NamedParameterJdbcTemplate,If I pass the date like ‘2020-05-30’,it also runs well.But when I pass ‘CURRENT_DATE’ or ‘curdate()’,it could not search any result.How to change my code? Answer It doesn’t work, because the
Can I use a randomly generated number as a parameter to a method in Java?
So I’m very new to Java so this question might have a pretty simple answer. I’m trying to create a Magic8 ball program and I want the fortune to depend on the randomly generated number, but it’s …
Firebase Datasnapshot returns null value
I want to retrieve this value from this node (“id”), and the value i get is null. I have googled so many solutions that this might have to do with asynchronous way or something, i guess? This is the database, and the highlighted node is the value i would like to get: This is my code: Most appreciated if someone
Validating elements of a 2D array
My code for making sure an element isn’t over 100 or less than 0 is: Except no matter what the input is the answer is always true My input array is test should = false if I input this no? College rules mean I cannot use break; or return anywhere other than the end of the sub module. Answer You
How to get user details from keycloak (not logged in user but any user by his id)
In my Java web application with Spring Boot I have Keycloak authentication done but now I need to get user details of some user by id (not user that is logged in). Is it possible ? I want to get his roles, groups and data from Java code. Answer You can use the REST API by getting an access token
Thymeleaf – output variable without a tag
I use Thymeleaf as a templating engine and I usually output variable value like this: in Java I set: and in html template I output: This works great, but I would like to output a variable without the need of a tag. Something following would be great: Unfortunately it does not work. My goal is to avoid unnecessary tag to