Carl Anton

+ Follow
since Aug 17, 2017
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Carl Anton

I have a command that takes a search query in xml format as an argument.
The  xml is quite big so I dont want it in the source code, I was thinking if I could put it in the resources folder and somehow read it and replacing a dynamic value (the search word) using a placeholder and shove it into the function.
I'm using Spring Boot 2.
Is there some functionality to do this in the spring framework or should I just create a reader and do it with a string replace?

4 months ago
Maybe Apache Camel or Spring Integration can help with the ftp part? I haven't used them before.
11 months ago
I’m going to build my first spring boot app and am wondering where to begin, what components to use etc. i’m pretty new to Java in general. The app will fetch a zip file by ftp or sftp from a remote server - it’s important it retries and that I get a notification by mail and slack if this fails because the file is important and it gets updated every week. After that it will unzip the file, process the xml files inside it and store the files ond disk and update a mysql database. This app will also have a healthchwck url which reports if the frp endpoint ans mysql db is reachable.
11 months ago
Thanks, I get it.
However, as some methods can be really time consuming on one variant of lists, like geting the n:th element out of a linked list is slow while doing it against ArrayList is prefferred. Isn't that worth keeping the prefferred type so that it's more clear what you are working with? Does the IDE perhaps show this in hints? (Using intellij).
1 year ago
I see both of these initializations here and there.. why use one over the other?

List<String> listStrings = new ArrayList<>();

ArrayList<String> listStrings = new ArrayList<>();
1 year ago
I want to make a real simple app that selects from mysql and loops through the result and update another mysqldatabase.

In PHP where I'm coming from, there are several ways to do this.
You could use the "standard" mysql-commands like mysql_connect() etc but that is considered bad practice and now whenever I use mysql in PHP i use the PDO-functions instead with prepared statements.
How should I go about doing this in Java the best way?

Also, this small app that will live just a couple of months - is it overkill to use Maven and or Spring Boot to set it up?
1 year ago
Thanks for the tips.
Binarysearch put me on the right path.
This code did the trick, I don't know, it feels a bit convoluted, but the tests pass!

1 year ago
Hi! I'm trying to solve this test:,11909&generatorId=27&type=fromtest&testDifficulty=Hard

Implement function countNumbers that accepts a sorted array of integers and counts the number of array elements that are less than the parameter lessThan.

For example, SortedSearch.countNumbers(new int[] { 1, 3, 5, 7 }, 4) should return 2 because there are two array elements less than 4.

I can get the basic tests to pass but I fail both performance tests. How can I speed this up?

This is what I have tried:


1 year ago
Thanks! Unfortunately Itext isn't free any longer in a proprietary environment.
As per this thread , I've started building my first java program for prod.

I'm using Maven to build it and the first step is to export all the images from a multi page tiff to a single pdf.

One of the biggest headscratches for me is to know what library to choose. If I use the suggestion from my first google hit it's possible I'll start to work on some deprecated library that noone else is using so I wanna try to pick them with care.

After getting the suggestion here in my other thread, and confirming with some googling, PDFBox is my choise for PDF-generation. When it comes to Tiff-processing, JAI looks promising, and I found some example code here: .

Are these libs alright?
And my second question - how do I go about making a single java file out of this that I can deploy rather than having loads of class-files in there (going to run this from cron every day).
Cool, I think I'll have a look at Maven then as I heard the senior Java devs in the company use it. I don't wanna bother them with too noobish questions just yet so I guess I'll be posting a bit here with basic stuff while I get my feet wet
1 year ago
I've been programming PHP for 15 years and want to learn something new so I've decided to try to do some of my projects at work in Java. My boss doesn't care as long as it gets the job done.
I've managed to compile and run a few programs now but im curious how I should set up my projects and what frameworks and build tools etc to use (if any).

Here are a couple of projects that I want to do. I use the IntelliJ editor and the server which will host the programs has Java 8 runtime - and we are thinking of maybe installing Docker on the machine later for Spring projects.

- A cronjob will trigger a program that fetches files from an ftp server and injects the data into a mysql database.
- A program will convert image files to pdf files and notify users on slack and sms.
- Build a REST microservice which queries a database and returns data as json.

I know how to program the classes to do the actual work, but everything else I have no idea about. Like Maven - i guess it is like the php version of "composer". Is it overkill to use it for these small projects? Are there better alternatives? Should I use Spring Boot? What do modern Java programmers use?

When looking for libraries etc to do PDF processing and FTP stuff, where should I look - is there some "official" repo of quality and well documented libraries?
1 year ago