In Python
I can join two paths with os.path.join
:
os.path.join(\"foo\", \"bar\") # => \"foo/bar\"
I\'m trying to
The most basic way is:
Path filepath = Paths.get("foo", "bar");
You should never write Paths.get("")
. I'm surprised that works at all. If you want to refer to the current directory explicitly, use Paths.get(System.getProperty("user.dir"))
. If you want the user's home directory, use Paths.get(System.getProperty("user.home"))
.
You can also combine the approaches:
Path filepath = Paths.get(
System.getProperty("user.home"), "data", "foo.txt");