• Post Reply Bookmark Topic Watch Topic
  • New Topic

Counting files in a directory  RSS feed

 
Brian Gulizia
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm just starting out on Java and am trying to modify some examples that are out there.

I want to display a file table that lists the name of a directory and how many files are in that directory. Eventually I'll add a refresh button and perhaps even an option to choose the directory when it launches but right now I'd like it to look at a static directory and count the number of files in all of the directories and subdirectories under that folder.

I've compiled and slightly modified the filetablehtml example:



Eliminating the read/write etc out of it.

I was looking at this example to incorporate:



but I can't get the 2nd piece of code to run. I don't know if I'm missing something when I type

java Utils
java Utils c:\windows
java Utils windows

Since I see that there is an @param I would assume I need to specify a directory but every time I do I get the same error: "Exception in thread "main" java.lang.NoSuchMethodError: main"


If someone could offer up a suggestion or 2, I'd appreciate it.

Thanks!

Damarr
 
Rob Spoor
Sheriff
Posts: 20898
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about adding a "public static void main(String[] args)" method to class Utils? Any class you run from the command line, as you are doing, needs that method.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!