I Have a folderName.txt
file which has a list of all the folders path.
How can i get the total count of the total number of files present inside that folder path.
For one path i'm able to do this like this.
new File("folder").listFiles().length.
But the Problems is i'm not able to read the path from the folderName.txt
file .
i'm trying this
File objFile = objPath.toFile();
try(BufferedReader in = new BufferedReader(
new FileReader(objFile))){
String line = in.readLine();
while(line != null){
String[] linesFile = line.split("\n");
But when i'm trying to access the linesFile array i'm getting an exception.
like linesFile[1]
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:.
My question is why i'm getting the java.lang.ArrayIndexOutOfBoundsException ?. and How could i read individual directory path and total number of files inside it. Is there way to read the total number of files in a subdirectory too.
folderName.txt has a structure like this.
E:/folder1
E:/folder2