IntelliJ, Java formatting: force empty blocks to be on one line
You can remove the unnecessary line breaks more universally throughout a project than just remove the newline before curly braces.
First go to the following setting and set a larger value for hard wrap:
Settings > Editor > Code Style
The default is 120. Change it to 250 or any other large value.
Next, navigate to the following setting:
Settings > Editor > Code Style > Java > Wrapping and Braces > Keep when reformatting > Line breaks
Uncheck "line breaks"
Finally, go back to your file and try to reformat the code.
This removes all the unnecessary line breaks that have been put into the code.
Enable following Simple blocks in one line
code style in settings.
Settings > Editor > Code Style > Java > Wrapping and Braces > Keep when reformatting > Simple blocks in one line
There is no way to do it for reformatting code.
This can only be done manually.
Check your Code Style settings, under "Alignment and Braces" to preserve your formatting. You should find a "Simple methods in one line" option there. Check it and clear the "Line breaks" check box.