In my case i need to copy a file from local folder to shared location.
Files.copy(new File("C:\\Users\\Public\\Pictures\\Sample Pictures\\Tulips.jpg").toPath(), new File("\\\10.101.1.2\\resources\\Files\\exbury\\Tulips.jpg").toPath(),
java.nio.file.StandardCopyOption.REPLACE_EXISTING);
java.nio.file.InvalidPathException: Illegal char <> at index 1: \.101.1.2\ZoneResources\File Share\burusoth\Tulips.jpg 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.io.File.toPath(File.java:2234) at com.zone.qv2.s2c.resultupload.TestClass.method(TestClass.java:31) at com.zone.qv2.s2c.resultupload.TestClass.main(TestClass.java:22)
It means NIO doesn't allow slashes \
in front of a path as said in this question. In my case i have to specify shared location as url which starts with slashes
. How can i overcome this issue?
Is there are any ways to copy files from local location to shared location?