Java NIO file path issue

java, nio

Solution

The path `\C:\Sample\sample.txt` must not have a leading `\`. It should be just `C:\Sample\sample.txt`

Problem

I used the following code to get the path ``` Path errorFilePath = FileSystems.getDefault().getPath(errorFile); ``` When I try to move a file using the File NIO, I get the error below: ``` java.nio.file.InvalidPathException: Illegal char <:> at index 2: \C:\Sample\sample.txt ``` I also tried using `URL.encode(errorFile)` which results in the same error.

Original source