You forgot to initialize
each element in the files
array. It would throw a NPE
.
long totalFileSizeOfAllFiles = 0;
for(int i=0;i < filename.length;i++){
files[i] = new File(filename[i]); // This is required.
long filesizeinbytes=files[i].length(); // Also length is a method.
totalFileSizeOfAllFiles+=filesizeinbytes; // To get the total size of all the files present.
P.S:- The assumption here is that each entry in the filename[]
array is a proper absolute/relative path to each file under consideration!