• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hard drive search

 
Eibhlin Reid
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know if it's possible to write a program in Java to search your hard drive? If so, any pointers?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

Not only possible, but easy. Something like this gets asked in our I/O and Streams forum about once a week, so I'm going to move this post over there.

Meanwhile, the answer is basically to use the java.io.File class. Find the filesystem roots using the appropriate method in that class, use one of the listXXX methods to create a directory listing, then look at all the files, and recursively check those File objects which are themselves directories.
 
Eibhlin Reid
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, that's going to help alot! Is it also possible to search the registry in the same way?... I probably should post a new topic for that question?!
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"The registry" is a Windows-specific concept, and as such, there's no Java API to work with it. You options all involve some native code -- either executing an external program, or calling native methods with the JNI interface.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!