same as title; how to access to UNC location in ShareFolder?
URL uri = new URL("file:\\\\x.x.1.10\\myUNC");
File file = new File(uri);
or
URL uri = new URL("file://x.x.1.10/myUNC");
File file = new File(uri);
also doesn't works.
same as title; how to access to UNC location in ShareFolder?
URL uri = new URL("file:\\\\x.x.1.10\\myUNC");
File file = new File(uri);
or
URL uri = new URL("file://x.x.1.10/myUNC");
File file = new File(uri);
also doesn't works.
Just:
File f = new File("\\\\x.x.1.10\\myUNC");
Using forward slashes (/
) instead of backslashes with the file
protocol will work to access a UNC location:
URI uri = URI.create("file:////SERVER/some/path");
Be sure, however, not to call URI.normalize()
or URI.resolve()
or it will break the UNC URI by removing too many slashes. The official bug: URI.normalize() ruins URI built from UNC File
On Windows2012 R2 this worked for me
java.nio.file.Files.copy(
Paths.get("\\\\xxxx/CRR/S20-1141_2020-03-16_ADDN1.txt"), destination, standardoptions);
The file share server is \\ (with \ escaped) but rest all /
using Java 8 240 build