1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| private long sizeOfIndex() {
long size = 0;
long totSize=0;
File indexGen = new File(Home.getConf().getValueOf("rootStore"));
try {
totSize += crawlFiles(indexGen, size);
System.out.println("totSize: "+totSize);
} catch (IOException ioe) {
Home.setLogError(" caught a " + ioe.getClass()
+ "\n with message: " + ioe.getMessage());
}
return totSize / 1024;
}
static long crawlFiles(File fil, long size) throws IOException {
// browse the directories
if (fil.isDirectory()) {
String[] files = fil.list();
// an IO error could occur
if (files != null) {
for (int i = 0; i < files.length; i++) {
size+=crawlFiles(new File(fil, files[i]), size);
}
}
} else {
size += fil.length();
}
return size;
} |