• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

File System in java

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!!
 
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
refer to Java File System.
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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....
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic