1

I have a java.nio.file.Path object that represents some directory (e.g., /var/log). I want a new Path object representing a file within the directory (e.g., /var/log/something.log). I have been using

Path logDir = ...
Path logFile = Paths.get(logDir.toString(), "something.log");

But it seems silly to have to turn logDir into a string, then construct the new Path object. How can I get the logFile object but without using toString? E.g.,

Path logDir = ...
Path logFile = Paths.get(logDir, "something.log"); // Doesn't exist
3
  • logDir.resolve? Check this stackoverflow.com/questions/8227499/… Commented Feb 19, 2013 at 19:40
  • Yes, exact duplicate but with a better title. Commented Feb 19, 2013 at 19:52
  • @anoopelias yup, that answers it! I voted to close this question Commented Feb 19, 2013 at 20:18

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.