This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Hi All, From java is it possible to locate the root directories and files residing them, from the machines in the local network ? I want something like network neighbourhood type application , so that i can view and select file from network machine Thanks in advance!!
From java is it possible to locate the root directories and files residing them, from the machines in the local network ? The static method File.listRoots() returns a File[] array listing all the system root directories. On Unix OSs, including Linux, that will return the single root directory ("/"); on Windows platforms it will return the roots of all mounted drives on the system. You can then recursively create a tree structure of the file systems by testing whether or not each file is a directory with File.isDirectory() and if it is you can call File.listFiles() which also returns a File[] array. [ May 28, 2003: Message edited by: Michael Morris ]
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Note that, on Windows, this just lists the roots of those directories that have lettered drives (have been mounted). This does not return machine names on the network neighborhood (or from the Chooser if you're on a Mac ). I'm not sure how one would go about getting that information....
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Michael Morris
Ranch Hand
Joined: Jan 30, 2002
Posts: 3451
posted
0
I'm not sure how one would go about getting that information.... When Sun gets off their ass and gives us raw sockets so we can query the network.
Michael Morris
Ranch Hand
Joined: Jan 30, 2002
Posts: 3451
posted
0
Here's some code I wrote a while back showing how to create a JTree of the local file system. This code is very inefficient, it takes over two minutes on my machine to create the top level node in the tree. So be patient and be warned. ExplorerTree.java
TreeExplorer.java
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.