Skip to content

Tag: java

Converting a string to a hash integer

I have to convert a string of length k with 4 possible characters – {A, C, G, T} – into an integer between 0 and 4^k. The advice is to convert the {A, C, G, T} into {0, 1, 2, 3} respectively, but I do not know how to convert those numbers into a number between 0 and 4^k. For

UnknownElementException on Java 17 record class

With excitement I downloaded Java 17 today and got a simple record class However when doing mvn compile, it throws me error Fatal error compiling: javax.lang.model.element.UnknownElementException: Unknown element: “com.xxx.TestCls” I double checked java -version and it looks right to me: Would any…

iText: Set height of table cell with image

I created a table with iText 5.5.13.2 (latest iText5 version) and I’m filling it with text and images that are read from a specific folder on the same PC: Both columns in the table use the same width (which is great) and big images are automatically resized to fit the width (which is also great), the on…

Spring boot how to use @PostConstruct correctly

Spring boot 2.5.4 I used @PostConstruct for the very first time in my service class. As following:- This method is called as soon as app launched. That is my requirements to process all file as soon as the app starts. I have controller as following:- My app starts on port 8080 and no exception at all. But whe…

Uploading files to S3 in Multithreading

I’m uploading files to s3 using the s3 AWS client in my spring application, but sometimes I’m getting the error, So as a solution to this I used the following approach and it worked for now. I have created this as a Spring Bean. But I am using this in a multithreading environment. So there will ma…

Using Stream API to count stats

I have following model representing a Snack bar SnackBarStat – This has a start date for a booking, number of customers in booking and number of Days(customer can set a start date and say for how many days they want to have table) Now given a list of such stats I am trying to find for each date how many