System.out is generally a buffered stream, and won’t flush until it either encounters a newline character ("\n") or you use one of the println methods or you flush it yourself with .flush().
That being said, I tried your example in IntelliJ. Using either println or the newline character caused the output to be flushed as I predicted, but using .flush() didn’t. So I tried using the Gradle application plugin and running it from the terminal using “gradle run”. And here the string was printed immediately without even requiring a flush. But running the application from IntelliJ using the same “run” task again didn’t show anything in the terminal immediately. So I expect that there is another buffer with the same behaviour somewhere, maybe in the Gradle Tooling API or in the way IntelliJ uses it.
In any case, can’t you just end the output with a newline?