I need to construct a path which contains colon (:). Actually the path is not a folder/directory in windows/linux. It is just a path of JCR repo. Below code gives InvalidPathException when the path contains colon
import java.nio.file.Path;
import java.nio.file.Paths;
public class TestCLass {
public static void main(String[] args) {
final Path path = Paths.get("com", "repo:access","resource");
//final Path path = Paths.get("com", "repoaccess","resource"); //Output - com/repoaccess/resource
System.out.println(path);
}
}
Exception
Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <:> at index 8: com\repo:access\resource
at sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
at java.nio.file.Paths.get(Paths.java:84)
Is there any API to access colon(:) and any other special character?