File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes Related to file count in xyz drive Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Related to file count in xyz drive" Watch "Related to file count in xyz drive" New topic
Author

Related to file count in xyz drive

upanshu vaid
Ranch Hand

Joined: Sep 07, 2012
Posts: 73

Hi,
I wanted to know how many files and directories are there in my x,y or z drive and if there is directory how many files and directories are there in this directory like this,
what I am able to get is the number of files and directories in x,y or z drive but not able to get "if there is directory how many files and directories are there in this directory"
I am using the below to code

upanshu vaid
Ranch Hand

Joined: Sep 07, 2012
Posts: 73

Just add to that I am using windows 7 in which // is used to give a pathname to a file or directory
Piet Souris
Ranch Hand

Joined: Mar 08, 2009
Posts: 700
    
  11
hi upanshu,

first of all: use Code tags!I have no doubt you've heard of these, since this is your 24th post. Not only does that make a code listing much more readable, but it also gives a replier the chance to point to a specific line.

Make a method (must be static in your example) that takes a file as an argument, counts the number of files in that file, and for each file in that file that is a directory, do a recursion with that specific file as argument. You've written the code that goes into this method already.

Hope this helps.

Greetz,
Piet
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Related to file count in xyz drive