File / Directory Network Path Using Java

How to get network path to file or directory on windows computer using java? Usually we see this in the properties of public folders in windows. As shown below ..... enter image description here

+4
source share
2 answers

Using Java, you can pass the net SHARE command to the exec method of the Runtime class, and then parse the output from the Process class to get the appropriate network path in your directory. The output of the net SHARE directory_name command is as follows:

 Share name Share Path C:\Share Remark Maximum users No limit Users Caching Manual caching of documents Permission user, FULL 

You need to get the Path key value from the above output. Below is the pseudo code on how you can do this:

  Process process = Runtime.getRuntime().exec("net SHARE directory_name"); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); StringWriter writer = new StringWriter(); String line; while (null != (line = reader.readLine())) { writer.write(line); } System.out.println(writer.toString()); 
+2
source

API for calling WNetEnumResource . You must use JNI to call the Windows API. An example can be found at http://public.m-plify.net/sourcecode/ .

0
source

All Articles