Is it possible to use a URI to create a File object representing a file on a REMOTE Window$ LAN share? If so does anyone have an example of the String representation of the URL such as file:/ etc. from which the following could be done: new File(new URL("file:/etc").toURI()?
Ryan Arthur Greenwood wrote:No I'm afraid not Rob. fileObject.exists() returns false. I think that File can only represent local files, hopefully I am wrong .
You are most definitely wrong
I've been able to access files on shares all the time, just using File in the way I've shown. Are you sure you have enough rights to that file? What happens if you use the same file in explorer?
If that still won't work, possibly because you need another user, JCIFS might be able to help you out.
Yes thankfully I was wrong. The issue is security. The answer is to map a drive to the share with suitable authentication and then use the mapping as a URL such as:
URL url = new URL("file:/Z:/testfile.txt");
File f = new File(url.toURI());