TIL Getting the Path for a file in the current directory

When writing a CLI application which operates on a file, you often want to look for that file in the current directory by default.

Let's say you have a --file parameter, which expect the full path to a pom.xml file, but looks for that file in the current directory if the parameter is not provided.

But how would you get the Path to the file in the current directory? Turns out, it's actually quite simple:

Paths.get("pom.xml").toAbsolutePath()

Bonus:

To get the Path for the current directory, you can just use:

Paths.get("").toAbsolutePath()