Have a look at the File class and its functions such as isDirectory() & exists(). For example,
import java.io.File;
public class Test {
public static void main(String[] args) {
File file = new File("\\\\server01\\\\folder");
System.out.println(file.isDirectory());
System.out.println(file.exists());
}
}
For a valid UNC path, this would print:
true
true
For in invalid, i.e. unaccessible, this would print:
false
false
NB: You need the 4 slashes to represent "\" as '\' is used for escape sequences.