Need to read shared directories on remote PC

G

google khan

Hi,
i just want to read the shared directories on PCs those are in my
network. e.g. In windows anyone can set any directory/file as shared.
and anyone who can access that domain, can see which all directories
are shared by the user of that machine.
I want to access those shared directories using JAVA.
can any body tells me how to get the info about those shared
directories?

thanks in advance,
 
J

John B. Matthews

google khan said:
just want to read the shared directories on PCs those are in my
network. e.g. In windows anyone can set any directory/file as shared.
and anyone who can access that domain, can see which all directories
are shared by the user of that machine. I want to access those shared
directories using [Java]. can anybody tell me how to get the info
about those shared directories?


You can use File on any mounted file system:

<http://java.sun.com/javase/6/docs/api/java/io/File.html>

Here's a simple example that recursively lists all files on the path
specified on the command line, or your current directory by default:

<code>
public class ListDir {

public static void main(String args[]) {
File root;
if (args.length > 0) root = new File(args[0]);
else root = new File(System.getProperty("user.dir"));
ls(root);
}

/** iterate recursively */
private static void ls(File f) {
File list[] = f.listFiles();
for (File file : list) {
if (file.isDirectory()) ls(file);
else System.out.println(file);
}
}
}
</code>

For everything else, there's Samba:

<http://www.samba.org/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top