Is there a way to read a file from a shared network location in windows?
Say, for example, I have this simple code that reads a text file readMe.txt from the Addons folder.
import java.io.File; class Sample{ public static void main(String[] ar){ File file = new File("Addons/ReadMe.txt"); System.out.println(file.getAbsolutePath());
And I run this file using the windows runme.bat package which has
java Sample PAUSE
The bat starts and executes the above class only when I put the Addons folder with the file ReadMe.txt, Sample.class, runme.bat on my local disk.
When it is placed in a shared network attached storage with a UNC loop, for example \\ name \ Shared
In such a scenario, the bat file usually starts the base from C: \ Windows and throws a NotFoundException class exception. I can map the shared drive to * Z: * or another drive, but I donβt want to do this.
I want the code to programmatically detect and retrieve the contents of Readme.txt in the Addons folder, whether it runs on a local drive or on a shared drive. Is there any way to achieve this? Please, help..
thanks
Veekay
source share