java.nio.file.Path error with VSS (Volume Shadow Copy) paths
Using VSS, I've created a volume snapshot and can successfully access files on it: C:\> type \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Users\Eric\Desktop\test.txt test text 1/2 test text 2/2 When I try to access the same file from java using java.io.File it works fine. However I am unable to convert it to a java.nio.file.Path by calling toPath like this: File file = newFile(vssPath) Path path = file.toPath() Doing so results in an exception trace. This is a known issue for OpenJDK and I get the same result with java 1.8.91: STACKTRACE:: java.nio.file.InvalidPathException: Illegal character [?] in path at index 2: \\? \GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Users\qa\Desktop\lock_full.txt at sun.nio.fs.WindowsPathParser.nextSlash(Unknown Source) at sun.nio.fs.WindowsPathParser.parse(Unknown Source) at sun.nio.fs.WindowsPathParser.parse(Unknown Source) at sun.nio.fs.WindowsPath.parse(Unknown Source) at sun.nio.fs.WindowsFileSystem.getPath(Unknown Source) at java.io.File.toPath(Unknown Source) Since I can't get a Path there are certain APIs I'm unable to use, for example java.nio.channels.AsynchronousFileChannel which can only be instantiated with a Path. Is there any alternative syntax for accessing the shadow copy file that won't run afoul of this JDK limitation? The OpenJDK ticket linked above recommends just omitting the long-UNC prefix (\\?) but I haven't found any variation of this that seems to be legal. For example the following all fail: C:\> type \\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Users\Eric\Desktop\test.txt C:\> type \\Device\HarddiskVolumeShadowCopy1\Users\Eric\Desktop\test.txt C:\> type \\HarddiskVolumeShadowCopy1\Users\Eric\Desktop\test.txt If there's no variant path I can use to call toPath() then is there some other way I could acquire a java.nio.file.Path that doesn't run afoul of the parser limitation?
In the absence of a timely workaround, my team discussed: create our own implementation of java.nio.file.Path (or find one in some other library) change code to avoid the use of java.nio.file.Path ... and we settled on #2. #1 would be a more general workaround should probably be the accepted answer if somebody ever does it and shares.
LinkedIn - how to pass query parameter
JAVA Graph/DFS implementation
Guava Cache, how to block access while doing removal
Disable key bindings in eclipse
Java - memory mapped file and flushing
Android : apache HttpComponents Core
Java create URL to arabic filename
Smoothly change position of images
How to make two objects equal to pass assertEquals()?
Create ComboBox within a TitleAreaDialog (JFace dialog)
JComboBox in JTable display invalid data
Vaadin JPAContainer and Tree drag and drop
Jersey with PathParams
How to check how many numbers in array are under 499?
Hash function for sorting words from file
Number of Pivots in Quick Sort