Help with getting the sum of files in a directory
I am trying to find the the size of some files in a directory. Then i want to get the sum of those. I have it set up to list all of the files but it returns a value of 0 for all the files. Once i can return the correct sizes i should have not problem adding them. Does someone see where my error is in my code?
import java.io.*;
publicclass DirectorySize{
publicstaticvoid main(String args[])throws IOException{
File file1 =new File("C://Documents and Settings/Tedd/My Documents/School/CST 200/");
System.out.println("File Name:" + file1.getName());
System.out.println("Path:" + file1.getPath());
System.out.println("Abs Path:" + file1.getAbsolutePath());
System.out.println("is a directory" + file1.isDirectory() );
System.out.println("File size:" + file1.length() +" Bytes");
String[] dirListing = file1.list();
for (int i = 0; i < dirListing.length; i++){
System.out.println(dirListing[i]);
System.out.println("File size:" + file1.length() +" Bytes");
}
}}

