Reputation: 2005
Here is my code:
public static Path changePath(Path pathInput) throws IOException
{
Path pathOutput = pathInput;
System.out.println(pathOutput);
pathOutput.resolve("test.xxx");
System.out.println(pathOutput);
return pathOutput;
}
pathInput is a directory. pathOutput should return a file with the directory + / + test.xxx
Both System.out.println lines output the same string; the pathInput!
Perhaps the problem lies with the line pathOutput = pathInput
. I tried to create a new Path() object but it said that you couldn't.
Regards.
Upvotes: 1
Views: 1326
Reputation: 279960
Path
is immutable. As the javadoc states
Implementations of this interface are immutable and safe for use by multiple concurrent threads.
Reassign it
pathOutput = pathOutput.resolve("test.xxx");
before you return it.
Upvotes: 2