Why does this return false in java?
new File("\\\\10.10.1.4").exists()
but
new File("\\\\10.10.1.4\\dir").exists()
returns true.
If i open the first address (without 'dir') in windows explorer i see the content so i don't think it's a permission issue since windows can see it just fine
Same thing happens with File.listFiles(). The first address returns null but the second returns the actual content
Finally if all else fails, is there any other way to test if a UNC address (just the ip without directory) exists and to list its content?
\\10.10.1.4 is an address, not a share reference, it does not point to a mounted file system. \\10.10.1.4\dir points to a share point which is a mounted file system.
I'd be like sending a letter to a street address, but leaving of the house number...it's not got a point of context from which it can be delievered. The same goes here. Java doesn't see \\10.10.14 as File, thus it doesn't exist (from the context of a File)
File("\\10.10.1.4") doesn't exist.
File("\\10.10.1.4\") probably does.
The browser/explorer automatically adds the backslash and that's why it displays the contents.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With