• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Related to file count in xyz drive

 
upanshu vaid
Ranch Hand
Posts: 83
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 83
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1098
16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic