Even when the question is regarding Java 7, I think it adds value to know that from Java 11 onward, there is a static method in Path
class that allows to do this straight away:
With all the path in one String:
Path.of("/tmp/foo");
With the path broken down in several Strings:
Path.of("/tmp","foo");