As you've probably found, File's length() method returns an "unspecified" value if the File object represents a directory.
So I think you need to iterate through the contents of the directory, and for each element that is a file, get the length and add it to a cumulative counter field. For each element that is a directory (i.e., a subdirectory), you will need to repeat this process (using recursion) until you get down to the final level.
See File methods listFiles(), isFile(), and isDirectory().
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org