How to access network paths from Java on OSX?
java, macos
Solution
Either mount the partition and access it as any local directory or use a specialized library such as JCIFS or Apache Commons VFS.
Problem
I try to access a network folder / UNC path from Java on Mac OSX. On Windows, the following test program works fine (at least one of the tested paths): ``` public class PathTest { public static void main(String[] args) { for (String path : Arrays.asList( "\\\\myserver\\transfer", "//myserver/transfer", "file://myserver/transfer", "smb://myserver/transfer")) { File f = new File(path); System.out.println(path + ": " + f.getAbsolutePath() + ", " + f.exists()); Path p = Paths.get(path); System.out.println(path + ": " + p.toAbsolutePath() + ", " + Files.exists(p)); } } } ``` on Mac OS it fails to reach the folders: ``` \\myserver\transfer: /Users/tim/IdeaProjects/PathTest/\\myserver\transfer, false //myserver/transfer: /myserver/transfer, false file://myserver/transfer: /Users/tim/IdeaProjects/PathTest/file://myserver/transfer, false smb://myserver/transfer: /Users/tim/IdeaProjects/PathTest/smb://myserver/transfer, false ``` When I use Finder, I can access the Folder (using the Guest user), by using "smb://myserver/transfer". What's wrong? EDIT added NIO.2 test